@@ -79,7 +79,10 @@ const propTraps: ProxyHandler<{
7979} ;
8080
8181type UnboxLazy < T > = T extends ( ) => infer U ? U : T ;
82- type BoxedTupleTypes < T extends any [ ] > = { [ P in keyof T ] : [ UnboxLazy < T [ P ] > ] } [ Exclude < keyof T , keyof any [ ] > ] ;
82+ type BoxedTupleTypes < T extends any [ ] > = { [ P in keyof T ] : [ UnboxLazy < T [ P ] > ] } [ Exclude <
83+ keyof T ,
84+ keyof any [ ]
85+ > ] ;
8386type UnionToIntersection < U > = ( U extends any ? ( k : U ) => void : never ) extends ( k : infer I ) => void
8487 ? I
8588 : never ;
@@ -117,53 +120,20 @@ export function mergeProps(...sources: any): any {
117120 ) ;
118121}
119122
120- export function splitProps < T extends object , K1 extends keyof T > (
121- props : T ,
122- ...keys : [ K1 [ ] ]
123- ) : [ Pick < T , K1 > , Omit < T , K1 > ] ;
124- export function splitProps < T extends object , K1 extends keyof T , K2 extends keyof T > (
125- props : T ,
126- ...keys : [ K1 [ ] , K2 [ ] ]
127- ) : [ Pick < T , K1 > , Pick < T , K2 > , Omit < T , K1 | K2 > ] ;
128- export function splitProps <
129- T extends object ,
130- K1 extends keyof T ,
131- K2 extends keyof T ,
132- K3 extends keyof T
133- > (
134- props : T ,
135- ...keys : [ K1 [ ] , K2 [ ] , K3 [ ] ]
136- ) : [ Pick < T , K1 > , Pick < T , K2 > , Pick < T , K3 > , Omit < T , K1 | K2 | K3 > ] ;
137- export function splitProps <
138- T extends object ,
139- K1 extends keyof T ,
140- K2 extends keyof T ,
141- K3 extends keyof T ,
142- K4 extends keyof T
143- > (
144- props : T ,
145- ...keys : [ K1 [ ] , K2 [ ] , K3 [ ] , K4 [ ] ]
146- ) : [ Pick < T , K1 > , Pick < T , K2 > , Pick < T , K3 > , Pick < T , K4 > , Omit < T , K1 | K2 | K3 | K4 > ] ;
147- export function splitProps <
148- T extends object ,
149- K1 extends keyof T ,
150- K2 extends keyof T ,
151- K3 extends keyof T ,
152- K4 extends keyof T ,
153- K5 extends keyof T
154- > (
155- props : T ,
156- ...keys : [ K1 [ ] , K2 [ ] , K3 [ ] , K4 [ ] , K5 [ ] ]
157- ) : [
158- Pick < T , K1 > ,
159- Pick < T , K2 > ,
160- Pick < T , K3 > ,
161- Pick < T , K4 > ,
162- Pick < T , K5 > ,
163- Omit < T , K1 | K2 | K3 | K4 | K5 >
123+ type SplitProps < T , K extends ( readonly ( keyof T ) [ ] ) [ ] > = [
124+ ...{
125+ [ P in keyof K ] : P extends `${number } `
126+ ? Pick < T , Extract < K [ P ] , readonly ( keyof T ) [ ] > [ number ] >
127+ : K [ P ] ;
128+ } ,
129+ Omit < T , K [ number ] [ number ] >
164130] ;
165- export function splitProps < T > ( props : T , ...keys : Array < ( keyof T ) [ ] > ) {
166- const blocked = new Set ( keys . flat ( ) ) ;
131+
132+ export function splitProps < T , K extends ( readonly ( keyof T ) [ ] ) [ ] > (
133+ props : T ,
134+ ...keys : K
135+ ) : SplitProps < T , K > {
136+ const blocked = new Set < keyof T > ( keys . flat ( ) ) ;
167137 const descriptors = Object . getOwnPropertyDescriptors ( props ) ;
168138 const res = keys . map ( k => {
169139 const clone = { } ;
@@ -202,7 +172,7 @@ export function splitProps<T>(props: T, ...keys: Array<(keyof T)[]>) {
202172 propTraps
203173 )
204174 ) ;
205- return res ;
175+ return res as SplitProps < T , K > ;
206176}
207177
208178// lazy load a function component asynchronously
0 commit comments