Skip to content

Commit b267241

Browse files
committed
fix(language-core): generics with slots don't work with Vue 2.7
close #3241
1 parent 2548ebf commit b267241

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ export function generateGlobalTypes(vueCompilerOptions: VueCompilerOptions) {
66
return `export const __VLS_globalTypesStart = {};
77
declare global {
88
// @ts-ignore
9-
type __VLS_IntrinsicElements = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.IntrinsicElements, __VLS_PickNotAny<globalThis.JSX.IntrinsicElements, Record<string, any>>>;
9+
type __VLS_IntrinsicElements = __VLS_PickNotAny<import('${vueCompilerOptions.lib}/jsx-runtime').JSX.IntrinsicElements, __VLS_PickNotAny<globalThis.JSX.IntrinsicElements, Record<string, any>>>;
1010
// @ts-ignore
11-
type __VLS_Element = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.Element, globalThis.JSX.Element>;
11+
type __VLS_Element = __VLS_PickNotAny<import('${vueCompilerOptions.lib}/jsx-runtime').JSX.Element, globalThis.JSX.Element>;
1212
// @ts-ignore
1313
type __VLS_GlobalComponents = ${[
14-
`__VLS_PickNotAny<import('vue').GlobalComponents, {}>`,
14+
`__VLS_PickNotAny<import('${vueCompilerOptions.lib}').GlobalComponents, {}>`,
1515
`__VLS_PickNotAny<import('@vue/runtime-core').GlobalComponents, {}>`,
1616
`__VLS_PickNotAny<import('@vue/runtime-dom').GlobalComponents, {}>`,
1717
`Pick<typeof import('${vueCompilerOptions.lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>`
1818
].join(' & ')};
19+
type __VLS_BuiltInPublicProps =
20+
__VLS_PickNotAny<import('${vueCompilerOptions.lib}').VNodeProps, {}>
21+
& __VLS_PickNotAny<import('${vueCompilerOptions.lib}').AllowedComponentProps, {}>
22+
& __VLS_PickNotAny<import('${vueCompilerOptions.lib}').ComponentCustomProps, {}>;
1923
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
2024
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
2125

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,6 @@ function* generateComponentProps(
290290
yield `${ctx.helperTypes.OmitKeepDiscriminatedUnion.name}<InstanceType<typeof __VLS_fnComponent>['$props'], keyof __VLS_BuiltInPublicProps>`;
291291
yield endOfLine;
292292

293-
yield `type __VLS_BuiltInPublicProps =${newLine}`
294-
+ ` import('${options.vueCompilerOptions.lib}').VNodeProps${newLine}`
295-
+ ` & import('${options.vueCompilerOptions.lib}').AllowedComponentProps${newLine}`
296-
+ ` & import('${options.vueCompilerOptions.lib}').ComponentCustomProps${endOfLine}`;
297-
298293
if (scriptSetupRanges.defineProp.length) {
299294
yield `const __VLS_defaults = {${newLine}`;
300295
for (const defineProp of scriptSetupRanges.defineProp) {

test-workspace/tsc/vue2/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"../vue3",
99
],
1010
"exclude": [
11-
"../vue3/#2639",
1211
"../vue3/#2700",
1312
"../vue3/#3123",
1413
"../vue3/#3289",

0 commit comments

Comments
 (0)