@@ -28,40 +28,35 @@ export interface Hanlder {
28
28
}
29
29
30
30
// 处理tsx slots 类型问题
31
- export type WithVSlots < T extends Record < string , any > > = 'slots' extends keyof T
32
- ? {
33
- 'v-slots' ?: Partial < T [ 'slots' ] & { $stable : boolean ; default ( ) : VNodeChild } >
34
- [ name : string ] : any
35
- }
36
- : Record < string , any >
31
+ export type WithVSlots < T extends { } > = {
32
+ 'v-slots' ?: 'slots' extends keyof T
33
+ ? Partial < T [ 'slots' ] & { $stable : boolean ; default ( ) : VNodeChild } >
34
+ : Partial < { $stable : boolean ; default ( ) : VNodeChild } >
35
+ }
37
36
38
- export type WithSlotTypes < T extends Record < string , any > > = Omit < SetupContext , 'slots' > & {
39
- slots : Partial < T [ 'slots' ] & { default ( ) : VNodeChild } >
37
+ export type WithSlotTypes < T extends { } > = Omit < SetupContext , 'slots' > & {
38
+ slots : 'slots' extends keyof T ? Partial < T [ 'slots' ] & { default ( ) : VNodeChild } > : Partial < { default ( ) : VNodeChild } >
40
39
}
41
40
42
- type ModelProps < T extends Record < string , any > > = Exclude <
41
+ type ModelProps < T extends { } > = Exclude <
43
42
{
44
43
[ Prop in keyof T ] : T extends { [ k in Prop as `onUpdate:${k & string } `] ?: any } ? Prop : never
45
44
} [ keyof T ] ,
46
45
undefined
47
46
>
48
47
49
- export type WithVModel < T extends Record < string , any > , U extends keyof T = ModelProps < T > > = {
48
+ export type WithVModel < T extends { } , U extends keyof T = ModelProps < T > > = {
50
49
[ k in U as `v-model:${k & string } `] ?: T [ k ] | [ T [ k ] , string [ ] ]
51
50
}
52
51
53
- export type ComponentProps < T extends Record < string , any > > = ComponentPropsArray < T > | ComponentPropsObject < T >
52
+ export type ComponentProps < T extends { } > = ComponentPropsArray < T > | ComponentPropsObject < T >
54
53
55
- export type ComponentPropsObject < T extends Record < string , any > > = {
54
+ export type ComponentPropsObject < T extends { } > = {
56
55
[ U in keyof Omit < T , 'slots' > ] -?: Prop < any >
57
56
}
58
- export type ComponentPropsArray < T extends Record < string , any > > = UnionToTuple < keyof Omit < T , 'slots' > >
57
+ export type ComponentPropsArray < T extends { } > = UnionToTuple < keyof Omit < T , 'slots' > >
59
58
60
- export type ComponentSlots < T extends { props : any } > = T extends { props : infer U }
61
- ? 'v-slots' extends keyof U
62
- ? U [ 'v-slots' ]
63
- : Record < string , unknown >
64
- : never
59
+ export type ComponentSlots < T extends { props : any } > = T [ 'props' ] [ 'v-slots' ]
65
60
66
61
/** 为了阻止ts把不相关的类也解析到metadata数据中,用这个工具类型包装一下类 */
67
62
export type ClassType < T > = T
0 commit comments