11import * as RN from "react-native" ;
2- import { StringifiedStyles , NamedStyles } from './index.d' ;
32
43declare module "react-native-size-matters/extend" {
54 export function scale ( size : number ) : number ;
@@ -11,9 +10,24 @@ declare module "react-native-size-matters/extend" {
1110 export function ms ( size : number , factor ?: number ) : number ;
1211 export function mvs ( size : number , factor ?: number ) : number ;
1312
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+
1424 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+ } > ;
1731 } ;
1832 }
1933}
0 commit comments