|
1 | | -import { getCurrentInstance, Prop, provide, SetupContext, VNodeChild, VNodeProps } from 'vue' |
| 1 | +import { getCurrentInstance, provide, VNodeChild, VNodeProps } from 'vue' |
2 | 2 | import { getEmitsFromProps, useCtx, useProps } from '@/helper' |
3 | | -import { Hanlder, VueComponentStaticContructor } from '@/type' |
| 3 | +import { Hanlder, VueComponentStaticContructor, WithSlotTypes, WithVModel, WithVSlots } from '@/type' |
4 | 4 | import { RefHandler } from '@/decorators/ref' |
5 | 5 | import { ComputedHandler } from '@/decorators/computed' |
6 | 6 | import { HookHandler } from '@/decorators/hook' |
7 | 7 | import { LinkHandler } from '@/decorators/link' |
8 | 8 |
|
9 | 9 | export const GlobalStoreKey = 'GlobalStoreKey' |
10 | 10 |
|
11 | | -type VueComponentProps<T extends Record<string, any>> = Omit<T, 'slots'> & WithVSlots<T> & VNodeProps |
12 | | - |
13 | | -// 处理tsx slots 类型问题 |
14 | | -type WithVSlots<T extends Record<string, any>> = 'slots' extends keyof T |
15 | | - ? { |
16 | | - 'v-slots'?: Partial<T['slots'] & { $stable: boolean; default(): VNodeChild }> |
17 | | - [name: string]: any |
18 | | - } |
19 | | - : Record<string, any> |
20 | | - |
21 | | -type WithSlotTypes<T extends Record<string, any>> = Omit<SetupContext, 'slots'> & { |
22 | | - slots: Partial<T['slots'] & { default(): VNodeChild }> |
23 | | -} |
| 11 | +type VueComponentProps<T extends Record<string, any>> = Omit<T, 'slots'> & WithVModel<T> & WithVSlots<T> & VNodeProps |
24 | 12 |
|
25 | 13 | export abstract class VueComponent<T = Record<string, any>> { |
26 | 14 | /** 装饰器处理 */ |
@@ -93,16 +81,3 @@ export abstract class VueComponent<T = Record<string, any>> { |
93 | 81 | abstract render(ctx?: any): VNodeChild |
94 | 82 | abstract render(ctx?: any, cache?: any[]): VNodeChild |
95 | 83 | } |
96 | | - |
97 | | -export type ComponentProps<T extends Record<string, any>> = { |
98 | | - [U in keyof Omit<T, 'slots'>]-?: Prop<any> |
99 | | -} |
100 | | - |
101 | | -export type ComponentSlots<T extends { props: any }> = T extends { props: infer U } |
102 | | - ? 'v-slots' extends keyof U |
103 | | - ? U['v-slots'] |
104 | | - : Record<string, unknown> |
105 | | - : never |
106 | | - |
107 | | -/** 为了阻止ts把不相关的类也解析到metadata数据中,用这个工具类型包装一下类 */ |
108 | | -export type ClassType<T> = T |
0 commit comments