1
1
import * as RN from "react-native" ;
2
- import { StringifiedStyles , NamedStyles } from './index.d' ;
3
2
4
3
declare module "react-native-size-matters/extend" {
5
4
export function scale ( size : number ) : number ;
@@ -11,9 +10,24 @@ declare module "react-native-size-matters/extend" {
11
10
export function ms ( size : number , factor ?: number ) : number ;
12
11
export function mvs ( size : number , factor ?: number ) : number ;
13
12
13
+ type Scale = `${number } @s${'r' | '' } `;
14
+ type VerticalScale = `${number } @vs${'r' | '' } `;
15
+ type ModerateScale = `${number } @ms${number | '' } ${'r' | '' } `;
16
+ type ModerateVerticalScale = `${number } @mvs${number | '' } ${'r' | '' } `;
17
+ type Size = Scale | VerticalScale | ModerateScale | ModerateVerticalScale ;
18
+ type WithSize < T > = { [ P in keyof T ] : number extends T [ P ] ? Size | T [ P ] : T [ P ] } ;
19
+ type ViewStyle = WithSize < RN . ViewStyle > ;
20
+ type TextStyle = WithSize < RN . TextStyle > ;
21
+ type ImageStyle = WithSize < RN . ImageStyle > ;
22
+ type NamedStyles < T > = { [ P in keyof T ] : ViewStyle | TextStyle | ImageStyle } ;
23
+
14
24
export namespace ScaledSheet {
15
- export function create < T extends NamedStyles < T > | NamedStyles < any > > ( stylesObject : T ) : {
16
- [ P in keyof T ] : RN . RegisteredStyle < T [ P ] & Record < Extract < keyof T [ P ] , keyof StringifiedStyles > , number > >
25
+ export function create < T extends NamedStyles < T > | NamedStyles < any > > (
26
+ stylesObject : T ,
27
+ ) : {
28
+ [ P in keyof T ] : RN . RegisteredStyle < {
29
+ [ S in keyof T [ P ] ] : T [ P ] [ S ] extends Size ? number : T [ P ] [ S ] ;
30
+ } > ;
17
31
} ;
18
32
}
19
33
}
0 commit comments