@@ -7,9 +7,9 @@ type baseType<E> = string
7
7
| Record < string , boolean >
8
8
| [ string , { [ key in keyof E ] ?: E [ key ] } ]
9
9
| { [ key in keyof E ] ?: E [ key ] extends boolean | undefined ? string : Record < string , string > }
10
- type baseLoopType < E > = baseType < E > | Array < baseType < E > > ;
11
- type extraType < E > = { className ?: baseLoopType < E > | undefined , [ key : string ] : any } ;
12
- type TagParams = Array < [ TemplateStringsArray , any [ ] ] > ;
10
+ type baseLoopType < E > = baseType < E > | baseType < E > [ ] ;
11
+ interface extraType < E > { className ?: baseLoopType < E > | undefined , [ key : string ] : any }
12
+ type TagParams = [ TemplateStringsArray , any [ ] ] [ ] ;
13
13
14
14
type IntrinsicElementsKeys = keyof JSX . IntrinsicElements ;
15
15
type MasterComponentProps < K extends IntrinsicElementsKeys | React . ComponentType < any > , E extends object = object > = extraType < E > & ( Omit < ( K extends IntrinsicElementsKeys
@@ -22,7 +22,7 @@ type MasterComponentProps<K extends IntrinsicElementsKeys | React.ComponentType<
22
22
type MasterExoticComponent < K extends IntrinsicElementsKeys | React . ComponentType < any > , E extends object = object > = React . ForwardRefExoticComponent < MasterComponentProps < K , E > & React . RefAttributes < K > > & { tag : K , params : TagParams , default ?: MasterComponentProps < K , E > } ;
23
23
24
24
type ParamType < K extends IntrinsicElementsKeys | React . ComponentType < any > , E extends object = object > = ( ( props : MasterComponentProps < K , E > ) => baseLoopType < MasterComponentProps < K , E > > | undefined ) | baseLoopType < MasterComponentProps < K , E > >
25
- type ParamsType < K extends IntrinsicElementsKeys | React . ComponentType < any > , E extends object = object > = Array < ParamType < K , E > > ;
25
+ type ParamsType < K extends IntrinsicElementsKeys | React . ComponentType < any > , E extends object = object > = ParamType < K , E > [ ] ;
26
26
27
27
type ReturnType < K extends IntrinsicElementsKeys | React . ComponentType < any > , E extends object = object > = < F extends TemplateStringsArray | MasterExoticComponent < any > | baseType < E > > (
28
28
firstParam : F ,
@@ -36,14 +36,8 @@ type ReturnType<K extends IntrinsicElementsKeys | React.ComponentType<any>, E ex
36
36
const styled : {
37
37
[ key in IntrinsicElementsKeys ] : ( < E extends object = object > ( firstParam : TemplateStringsArray | ParamType < key , E > , ...params : ParamsType < key , E > ) => MasterExoticComponent < key , E > )
38
38
& ( < F extends MasterExoticComponent < any , any > , E extends object = object > ( firstParam : F ) => F extends MasterExoticComponent < any , infer ME > ? ReturnType < key , ME & E > : never )
39
- } & {
40
- < F extends MasterExoticComponent < any > , E extends object = object > ( firstParam : F ) : F extends MasterExoticComponent < infer K , infer ME > ? ReturnType < K , ME & E > : never
41
- } & {
42
- < E extends object = object > ( firstParam : TemplateStringsArray | ParamType < 'div' , E > , ...params : ParamsType < 'div' , E > ) : MasterExoticComponent < 'div' , E >
43
- } & {
44
- //@ts -ignore
45
- < F extends React . ComponentType < any > , E extends object = object > ( firstParam : F , ...params : F extends React . ComponentType < infer RE > ? ParamsType < 'div' , RE & E > : never ) : F extends React . ComponentType < infer RE > ? ReturnType < React . ComponentType < RE & E > > : never
46
- } = new Proxy (
39
+ } & ( < F extends MasterExoticComponent < any > , E extends object = object > ( firstParam : F ) => F extends MasterExoticComponent < infer K , infer ME > ? ReturnType < K , ME & E > : never ) & ( < E extends object = object > ( firstParam : TemplateStringsArray | ParamType < 'div' , E > , ...params : ParamsType < 'div' , E > ) => MasterExoticComponent < 'div' , E > ) & //@ts -ignore
40
+ ( < F extends React . ComponentType < any > , E extends object = object > ( firstParam : F , ...params : F extends React . ComponentType < infer RE > ? ParamsType < 'div' , RE & E > : never ) => F extends React . ComponentType < infer RE > ? ReturnType < React . ComponentType < RE & E > > : never ) = new Proxy (
47
41
( ( firstParam : any , ...params : any [ ] ) => {
48
42
return ( Array . isArray ( firstParam ) && 'raw' in firstParam || typeof firstParam !== 'object' || ! ( 'render' in firstParam ) )
49
43
? styled . div ( firstParam as any , ...params )
@@ -139,7 +133,7 @@ function handle<K extends IntrinsicElementsKeys | React.ComponentType<any>, E ex
139
133
}
140
134
break
141
135
case 'function' :
142
- // eslint-disable-next-line no-case-declarations
136
+
143
137
const transformedParam = param ( props )
144
138
if ( typeof transformedParam === 'object' && handleParam ( transformedParam ) )
145
139
return true
0 commit comments