File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
packages/vscode-vue-languageservice/src/utils Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,15 @@ export function getVueLibraryName(isVue2: boolean) {
10
10
return isVue2 ? '@vue/runtime-dom' : 'vue' ;
11
11
}
12
12
13
+ export function getSlotsPropertyName ( isVue2 : boolean ) {
14
+ return isVue2 ? '$scopedSlots' : '$slots' ;
15
+ }
16
+
13
17
export const typesFileName = '__VLS_types.ts' ;
14
18
15
19
export function getTypesCode ( isVue2 : boolean ) {
16
20
const libName = getVueLibraryName ( isVue2 ) ;
21
+ const slots = getSlotsPropertyName ( isVue2 ) ;
17
22
return `
18
23
import * as vue from '${ libName } ';
19
24
import type {
@@ -61,12 +66,12 @@ export declare function directiveFunction<T>(dir: T):
61
66
62
67
export type TemplateSlots<T> = T extends { __VLS_slots: infer S } ? S : {};
63
68
export type HasTemplateSlotsType<T> = T extends { __VLS_slots: infer _ } ? true : false;
64
- export type HasScriptSlotsType<T> = T extends new (...args: any) => { $slots?: infer _ } ? true : false;
69
+ export type HasScriptSlotsType<T> = T extends new (...args: any) => { ${ slots } ?: infer _ } ? true : false;
65
70
export type DefaultSlots<W, R> = HasTemplateSlotsType<W> extends true ? {}
66
71
: HasScriptSlotsType<R> extends true ? {}
67
72
: Record<string, any>;
68
- export type SlotsComponent<T> = T extends new (...args: any) => { $slots?: infer S } ? T : new (...args: any) => { $slots: {} };
69
- export type ScriptSlots<T> = T extends { $slots?: infer S }
73
+ export type SlotsComponent<T> = T extends new (...args: any) => { ${ slots } ?: infer S } ? T : new (...args: any) => { ${ slots } : {} };
74
+ export type ScriptSlots<T> = T extends { ${ slots } ?: infer S }
70
75
? { [K in keyof S]-?: S[K] extends ((obj: infer O) => any) | undefined ? O : S[K] }
71
76
: {};
72
77
You can’t perform that action at this time.
0 commit comments