Skip to content

Commit b14b8a9

Browse files
committed
refactor(language-core): generate global types for the first parsed Vue component
1 parent e3f8b91 commit b14b8a9

File tree

7 files changed

+140
-151
lines changed

7 files changed

+140
-151
lines changed

packages/component-meta/lib/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function baseCreate(
139139
const fileExists = languageServiceHost.fileExists.bind(languageServiceHost);
140140
const getScriptSnapshot = languageServiceHost.getScriptSnapshot.bind(languageServiceHost);
141141
const globalTypesName = `${commandLine.vueOptions.lib}_${commandLine.vueOptions.target}_${commandLine.vueOptions.strictTemplates}.d.ts`;
142-
const globalTypesContents = vue.generateGlobalTypes('global', commandLine.vueOptions.lib, commandLine.vueOptions.target, commandLine.vueOptions.strictTemplates);
142+
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + vue.generateGlobalTypes(commandLine.vueOptions.lib, commandLine.vueOptions.target, commandLine.vueOptions.strictTemplates);
143143
const globalTypesSnapshot: ts.IScriptSnapshot = {
144144
getText: (start, end) => globalTypesContents.substring(start, end),
145145
getLength: () => globalTypesContents.length,
Lines changed: 116 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,134 @@
11
import { getSlotsPropertyName } from '../utils/shared';
2-
import { endOfLine, newLine } from './common';
32

4-
export function generateGlobalTypes(mode: 'global' | 'local', lib: string, target: number, strictTemplates: boolean) {
3+
export function generateGlobalTypes(lib: string, target: number, strictTemplates: boolean) {
54
const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${strictTemplates ? '' : ' & Record<string, unknown>'}`;
5+
return `
6+
; declare module '${lib}' {
7+
export interface GlobalComponents { }
8+
}
9+
declare global {
10+
const __VLS_intrinsicElements: __VLS_IntrinsicElements;
11+
const __VLS_directiveBindingRestFields: { instance: null, oldValue: null, modifiers: any, dir: any };
12+
const __VLS_unref: typeof import('${lib}').unref;
613
7-
let decl = '';
8-
let str = '';
9-
let globalComponentsType: string;
14+
const __VLS_nativeElements = {
15+
...{} as SVGElementTagNameMap,
16+
...{} as HTMLElementTagNameMap,
17+
};
1018
11-
if (mode === 'global') {
12-
str += `// @ts-nocheck${newLine}`;
13-
str += `export {}${endOfLine}`;
14-
str += `declare module '${lib}' {${newLine}`;
15-
str += ` export interface GlobalComponents { }${newLine}`;
16-
str += `}${newLine}`;
17-
str += `declare global {${newLine}`;
18-
globalComponentsType = `import('${lib}').GlobalComponents`;
19-
}
20-
else {
21-
decl = 'declare ';
22-
str += `// @ts-ignore${newLine}`;
23-
str += `const __VLS_globalComponents = { ...{} as import('${lib}').GlobalComponents }${endOfLine}`;
24-
globalComponentsType = `void extends typeof __VLS_globalComponents ? {} : typeof __VLS_globalComponents`;
25-
}
26-
27-
str += `
28-
${decl}const __VLS_intrinsicElements: __VLS_IntrinsicElements;
29-
${decl}const __VLS_directiveBindingRestFields: { instance: null, oldValue: null, modifiers: any, dir: any };
30-
${decl}const __VLS_unref: typeof import('${lib}').unref;
31-
32-
const __VLS_nativeElements = {
33-
...{} as SVGElementTagNameMap,
34-
...{} as HTMLElementTagNameMap,
35-
};
36-
37-
type __VLS_IntrinsicElements = ${(
19+
type __VLS_IntrinsicElements = ${(
3820
target >= 3.3
3921
? `import('${lib}/jsx-runtime').JSX.IntrinsicElements;`
4022
: `globalThis.JSX.IntrinsicElements;`
4123
)}
42-
type __VLS_Element = ${(
24+
type __VLS_Element = ${(
4325
target >= 3.3
4426
? `import('${lib}/jsx-runtime').JSX.Element;`
4527
: `globalThis.JSX.Element;`
4628
)}
47-
type __VLS_GlobalComponents = ${(
29+
type __VLS_GlobalComponents = ${(
4830
target >= 3.5
49-
? globalComponentsType
50-
: `(${globalComponentsType}) & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`
31+
? `import('${lib}').GlobalComponents`
32+
: `import('${lib}').GlobalComponents & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`
5133
)}
52-
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
53-
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
54-
type __VLS_unknownDirective = (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
55-
type __VLS_WithComponent<N0 extends string, LocalComponents, N1 extends string, N2 extends string, N3 extends string> =
56-
N1 extends keyof LocalComponents ? N1 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N1] } :
57-
N2 extends keyof LocalComponents ? N2 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N2] } :
58-
N3 extends keyof LocalComponents ? N3 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N3] } :
59-
N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } :
60-
N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
61-
N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
62-
${strictTemplates ? '{}' : '{ [K in N0]: unknown }'}
63-
type __VLS_FunctionalComponentProps<T, K> =
64-
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
65-
: T extends (props: infer P, ...args: any) => any ? P :
66-
{};
67-
type __VLS_IsFunction<T, K> = K extends keyof T
68-
? __VLS_IsAny<T[K]> extends false
69-
? unknown extends T[K]
70-
? false
71-
: true
72-
: false
73-
: false;
74-
// fix https://github.com/vuejs/language-tools/issues/926
75-
type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
76-
type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R
77-
? U extends T
78-
? never
79-
: __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R)
80-
: never;
81-
type __VLS_OverloadUnion<T> = Exclude<
82-
__VLS_OverloadUnionInner<(() => never) & T>,
83-
T extends () => never ? never : () => never
84-
>;
85-
type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F
86-
? F extends (event: infer E, ...args: infer A) => any
87-
? { [K in E & string]: (...args: A) => void; }
88-
: never
89-
: never;
90-
type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal<
91-
__VLS_UnionToIntersection<
92-
__VLS_ConstructorOverloads<T> & {
93-
[K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never
94-
}
95-
>
96-
>;
97-
type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {};
34+
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
35+
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
36+
type __VLS_unknownDirective = (arg1: unknown, arg2: unknown, arg3: unknown, arg4: unknown) => void;
37+
type __VLS_WithComponent<N0 extends string, LocalComponents, N1 extends string, N2 extends string, N3 extends string> =
38+
N1 extends keyof LocalComponents ? N1 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N1] } :
39+
N2 extends keyof LocalComponents ? N2 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N2] } :
40+
N3 extends keyof LocalComponents ? N3 extends N0 ? Pick<LocalComponents, N0 extends keyof LocalComponents ? N0 : never> : { [K in N0]: LocalComponents[N3] } :
41+
N1 extends keyof __VLS_GlobalComponents ? N1 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N1] } :
42+
N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N2] } :
43+
N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : { [K in N0]: __VLS_GlobalComponents[N3] } :
44+
${strictTemplates ? '{}' : '{ [K in N0]: unknown }'}
45+
type __VLS_FunctionalComponentProps<T, K> =
46+
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: { props?: infer P } } ? NonNullable<P> : never
47+
: T extends (props: infer P, ...args: any) => any ? P :
48+
{};
49+
type __VLS_IsFunction<T, K> = K extends keyof T
50+
? __VLS_IsAny<T[K]> extends false
51+
? unknown extends T[K]
52+
? false
53+
: true
54+
: false
55+
: false;
56+
// fix https://github.com/vuejs/language-tools/issues/926
57+
type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
58+
type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R
59+
? U extends T
60+
? never
61+
: __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R)
62+
: never;
63+
type __VLS_OverloadUnion<T> = Exclude<
64+
__VLS_OverloadUnionInner<(() => never) & T>,
65+
T extends () => never ? never : () => never
66+
>;
67+
type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F
68+
? F extends (event: infer E, ...args: infer A) => any
69+
? { [K in E & string]: (...args: A) => void; }
70+
: never
71+
: never;
72+
type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal<
73+
__VLS_UnionToIntersection<
74+
__VLS_ConstructorOverloads<T> & {
75+
[K in keyof T]: T[K] extends any[] ? { (...args: T[K]): void } : never
76+
}
77+
>
78+
>;
79+
type __VLS_PrettifyGlobal<T> = { [K in keyof T]: T[K]; } & {};
9880
99-
${decl}function __VLS_getVForSourceType(source: number): [number, number, number][];
100-
${decl}function __VLS_getVForSourceType(source: string): [string, number, number][];
101-
${decl}function __VLS_getVForSourceType<T extends any[]>(source: T): [
102-
item: T[number],
103-
key: number,
104-
index: number,
105-
][];
106-
${decl}function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [
107-
item: T extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never,
108-
key: number,
109-
index: undefined,
110-
][];
111-
// #3845
112-
${decl}function __VLS_getVForSourceType<T extends number | { [Symbol.iterator](): Iterator<any> }>(source: T): [
113-
item: number | (Exclude<T, number> extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never),
114-
key: number,
115-
index: undefined,
116-
][];
117-
${decl}function __VLS_getVForSourceType<T>(source: T): [
118-
item: T[keyof T],
119-
key: keyof T,
120-
index: number,
121-
][];
122-
// @ts-ignore
123-
${decl}function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
124-
// @ts-ignore
125-
${decl}function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
126-
${decl}function __VLS_directiveAsFunction<T extends import('${lib}').Directive>(dir: T): T extends (...args: any) => any
127-
? T | __VLS_unknownDirective
128-
: NonNullable<(T & Record<string, __VLS_unknownDirective>)['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']>;
129-
${decl}function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
130-
${decl}function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
131-
${decl}function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T;
132-
${decl}function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
133-
T extends new (...args: any) => any
134-
? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & { __ctx?: {
135-
attrs?: any,
136-
slots?: K extends { ${getSlotsPropertyName(target)}: infer Slots } ? Slots : any,
137-
emit?: K extends { $emit: infer Emit } ? Emit : any
138-
} & { props?: ${fnPropsType}; expose?(exposed: K): void; } }
139-
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
140-
: T extends (...args: any) => any ? T
141-
: (_: {}${strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${strictTemplates ? '' : ' & Record<string, unknown>'} } };
142-
${decl}function __VLS_elementAsFunction<T>(tag: T, endTag?: T): (_: T${strictTemplates ? '' : ' & Record<string, unknown>'}) => void;
143-
${decl}function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
144-
${decl}function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): NonNullable<__VLS_PickNotAny<
145-
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any
146-
, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
147-
>>;
148-
${decl}function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
149-
${decl}function __VLS_tryAsConstant<const T>(t: T): T;
81+
function __VLS_getVForSourceType(source: number): [number, number, number][];
82+
function __VLS_getVForSourceType(source: string): [string, number, number][];
83+
function __VLS_getVForSourceType<T extends any[]>(source: T): [
84+
item: T[number],
85+
key: number,
86+
index: number,
87+
][];
88+
function __VLS_getVForSourceType<T extends { [Symbol.iterator](): Iterator<any> }>(source: T): [
89+
item: T extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never,
90+
key: number,
91+
index: undefined,
92+
][];
93+
// #3845
94+
function __VLS_getVForSourceType<T extends number | { [Symbol.iterator](): Iterator<any> }>(source: T): [
95+
item: number | (Exclude<T, number> extends { [Symbol.iterator](): Iterator<infer T1> } ? T1 : never),
96+
key: number,
97+
index: undefined,
98+
][];
99+
function __VLS_getVForSourceType<T>(source: T): [
100+
item: T[keyof T],
101+
key: keyof T,
102+
index: number,
103+
][];
104+
// @ts-ignore
105+
function __VLS_getSlotParams<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>;
106+
// @ts-ignore
107+
function __VLS_getSlotParam<T>(slot: T): Parameters<__VLS_PickNotAny<NonNullable<T>, (...args: any[]) => any>>[0];
108+
function __VLS_directiveAsFunction<T extends import('${lib}').Directive>(dir: T): T extends (...args: any) => any
109+
? T | __VLS_unknownDirective
110+
: NonNullable<(T & Record<string, __VLS_unknownDirective>)['created' | 'beforeMount' | 'mounted' | 'beforeUpdate' | 'updated' | 'beforeUnmount' | 'unmounted']>;
111+
function __VLS_withScope<T, K>(ctx: T, scope: K): ctx is T & K;
112+
function __VLS_makeOptional<T>(t: T): { [K in keyof T]?: T[K] };
113+
function __VLS_nonNullable<T>(t: T): T extends null | undefined ? never : T;
114+
function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K):
115+
T extends new (...args: any) => any
116+
? (props: ${fnPropsType}, ctx?: any) => __VLS_Element & { __ctx?: {
117+
attrs?: any,
118+
slots?: K extends { ${getSlotsPropertyName(target)}: infer Slots } ? Slots : any,
119+
emit?: K extends { $emit: infer Emit } ? Emit : any
120+
} & { props?: ${fnPropsType}; expose?(exposed: K): void; } }
121+
: T extends () => any ? (props: {}, ctx?: any) => ReturnType<T>
122+
: T extends (...args: any) => any ? T
123+
: (_: {}${strictTemplates ? '' : ' & Record<string, unknown>'}, ctx?: any) => { __ctx?: { attrs?: any, expose?: any, slots?: any, emit?: any, props?: {}${strictTemplates ? '' : ' & Record<string, unknown>'} } };
124+
function __VLS_elementAsFunction<T>(tag: T, endTag?: T): (_: T${strictTemplates ? '' : ' & Record<string, unknown>'}) => void;
125+
function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): 2 extends Parameters<T>['length'] ? [any] : [];
126+
function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): NonNullable<__VLS_PickNotAny<
127+
'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends { __ctx?: infer Ctx } ? Ctx : never : any
128+
, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any
129+
>>;
130+
function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
131+
function __VLS_tryAsConstant<const T>(t: T): T;
132+
}
150133
`;
151-
152-
if (mode === 'global') {
153-
str += `}${newLine}`;
154-
}
155-
return str;
156134
};

packages/language-core/lib/codegen/script/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export interface ScriptCodegenOptions {
4747
scriptSetupRanges: ScriptSetupRanges | undefined;
4848
templateCodegen: TemplateCodegenContext & { codes: Code[]; } | undefined;
4949
edited: boolean;
50+
appendGlobalTypes: boolean;
5051
getGeneratedLength: () => number;
5152
linkedCodeMappings: Mapping[];
5253
}
@@ -151,8 +152,8 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code,
151152
yield `type __VLS_IntrinsicElementsCompletion = __VLS_IntrinsicElements${endOfLine}`;
152153
}
153154
yield* ctx.localTypes.generate([...ctx.localTypes.getUsedNames()]);
154-
if (!options.vueCompilerOptions.__setupedGlobalTypes) {
155-
yield generateGlobalTypes('local', options.vueCompilerOptions.lib, options.vueCompilerOptions.target, options.vueCompilerOptions.strictTemplates);
155+
if (options.appendGlobalTypes) {
156+
yield generateGlobalTypes(options.vueCompilerOptions.lib, options.vueCompilerOptions.target, options.vueCompilerOptions.strictTemplates);
156157
}
157158

158159
if (options.sfc.scriptSetup) {

packages/language-core/lib/plugins/vue-tsx.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const fileEditTimes = new Map<string, number>();
1313

1414
const plugin: VueLanguagePlugin = ctx => {
1515

16+
let appendedGlobalTypes = false;
17+
1618
return {
1719

1820
version: 2.1,
@@ -51,7 +53,12 @@ const plugin: VueLanguagePlugin = ctx => {
5153

5254
function useTsx(fileName: string, sfc: Sfc) {
5355
if (!tsCodegen.has(sfc)) {
54-
tsCodegen.set(sfc, createTsx(fileName, sfc, ctx));
56+
let appendGlobalTypes = false;
57+
if (!ctx.vueCompilerOptions.__setupedGlobalTypes && !appendedGlobalTypes) {
58+
appendGlobalTypes = true;
59+
appendedGlobalTypes = true;
60+
}
61+
tsCodegen.set(sfc, createTsx(fileName, sfc, ctx, appendGlobalTypes));
5562
}
5663
return tsCodegen.get(sfc)!;
5764
}
@@ -62,9 +69,9 @@ export default plugin;
6269
function createTsx(
6370
fileName: string,
6471
_sfc: Sfc,
65-
ctx: Parameters<VueLanguagePlugin>[0]
72+
ctx: Parameters<VueLanguagePlugin>[0],
73+
appendGlobalTypes: boolean
6674
) {
67-
6875
const ts = ctx.modules.typescript;
6976
const lang = computed(() => {
7077
return !_sfc.script && !_sfc.scriptSetup ? 'ts'
@@ -172,6 +179,7 @@ function createTsx(
172179
edited: ctx.vueCompilerOptions.__test || (fileEditTimes.get(fileName) ?? 0) >= 2,
173180
getGeneratedLength: () => generatedLength,
174181
linkedCodeMappings,
182+
appendGlobalTypes,
175183
});
176184
fileEditTimes.set(fileName, (fileEditTimes.get(fileName) ?? 0) + 1);
177185

packages/language-core/lib/utils/ts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ export function setupGlobalTypes(rootDir: string, vueOptions: VueCompilerOptions
295295
dir = parentDir;
296296
}
297297
const globalTypesPath = path.resolve(dir, `node_modules/.vue-global-types/${vueOptions.lib}_${vueOptions.target}_${vueOptions.strictTemplates}.d.ts`);
298-
const globalTypesContents = generateGlobalTypes('global', vueOptions.lib, vueOptions.target, vueOptions.strictTemplates);
298+
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + generateGlobalTypes(vueOptions.lib, vueOptions.target, vueOptions.strictTemplates);
299299
host.writeFile(globalTypesPath, globalTypesContents);
300300
return true;
301301
} catch {

packages/language-server/lib/initialize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function initialize(
5656
const fileExists = project.typescript.languageServiceHost.fileExists.bind(project.typescript.languageServiceHost);
5757
const getScriptSnapshot = project.typescript.languageServiceHost.getScriptSnapshot.bind(project.typescript.languageServiceHost);
5858
const globalTypesName = `${vueCompilerOptions.lib}_${vueCompilerOptions.target}_${vueCompilerOptions.strictTemplates}.d.ts`;
59-
const globalTypesContents = generateGlobalTypes('global', vueCompilerOptions.lib, vueCompilerOptions.target, vueCompilerOptions.strictTemplates);
59+
const globalTypesContents = `// @ts-nocheck\nexport {};\n` + generateGlobalTypes(vueCompilerOptions.lib, vueCompilerOptions.target, vueCompilerOptions.strictTemplates);
6060
const globalTypesSnapshot: ts.IScriptSnapshot = {
6161
getText: (start, end) => globalTypesContents.substring(start, end),
6262
getLength: () => globalTypesContents.length,

0 commit comments

Comments
 (0)