Skip to content

Commit 4fae9dd

Browse files
committed
fix(language-core): re-fix Yarn PnP compatibility
1 parent 9e2aaf7 commit 4fae9dd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/language-core/lib/codegen/globalTypes.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export function generateGlobalTypes(mode: 'global' | 'local', lib: string, targe
55
const fnPropsType = `(K extends { $props: infer Props } ? Props : any)${strictTemplates ? '' : ' & Record<string, unknown>'}`;
66

77
let str = '';
8+
let globalComponentsType: string;
89

910
if (mode === 'global') {
1011
str += `// @ts-nocheck${newLine}`;
@@ -13,6 +14,11 @@ export function generateGlobalTypes(mode: 'global' | 'local', lib: string, targe
1314
str += ` export interface GlobalComponents { }${newLine}`;
1415
str += `}${newLine}`;
1516
str += `declare global {${newLine}`;
17+
globalComponentsType = `import('${lib}').GlobalComponents`;
18+
}
19+
else {
20+
str += `const __VLS_globalComponents = { ...{} as import('${lib}').GlobalComponents }${endOfLine}`;
21+
globalComponentsType = `void extends typeof __VLS_globalComponents ? {} : typeof __VLS_globalComponents`;
1622
}
1723

1824
str += `
@@ -31,8 +37,8 @@ type __VLS_Element = ${(
3137
)}
3238
type __VLS_GlobalComponents = ${(
3339
target >= 3.5
34-
? `import('vue').GlobalComponents;`
35-
: `import('vue').GlobalComponents & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`
40+
? globalComponentsType
41+
: `(${globalComponentsType}) & Pick<typeof import('${lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>;`
3642
)}
3743
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
3844
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;

0 commit comments

Comments
 (0)