File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,16 +147,18 @@ export default class Sugar<T> {
147147
148148 create < P extends NamedStyles < P > | NamedStyles < any > > (
149149 objFn : Fn < T , P > | P
150- ) : StyleSheetType < P > {
150+ ) : P extends NamedStyles < P > ? StyleSheetType < P > : P {
151151 if ( typeof objFn === 'function' ) {
152152 const sheet = new Sheet ( objFn ) ;
153153 this . sheets . push ( sheet ) ;
154154 if ( this . builded ) {
155155 sheet . calc ( this . theme , this . constants , this . activeIndex ) ;
156156 }
157- return sheet . getResult ( ) as StyleSheetType < P > ;
157+ return sheet . getResult ( ) as P extends NamedStyles < P >
158+ ? StyleSheetType < P >
159+ : P ;
158160 }
159- return objFn as StyleSheetType < P > ;
161+ return objFn as P extends NamedStyles < P > ? StyleSheetType < P > : P ;
160162 }
161163
162164 _calculateActiveIndex ( ) : void {
Original file line number Diff line number Diff line change @@ -21,10 +21,7 @@ export type NamedStyles<T> = {
2121
2222export type S = NamedStyles < any > ;
2323
24- export type Fn < T , P > = (
25- theme : T ,
26- constants : ConstantsType
27- ) => P extends NamedStyles < P > ? NamedStyles < P > : P ;
24+ export type Fn < T , P > = ( theme : T , constants : ConstantsType ) => P ;
2825
2926export type StyleSheetType < P > = {
3027 [ K in keyof P ] : {
Original file line number Diff line number Diff line change 11{
22 "name" : " react-native-sugar-style" ,
3- "version" : " 0.1.7 " ,
3+ "version" : " 0.1.8 " ,
44 "description" : " React Native Stylesheet alternative with theme support" ,
55 "author" : " mohit23x" ,
66 "license" : " MIT" ,
You can’t perform that action at this time.
0 commit comments