Skip to content

Commit

Permalink
fix(language-core): generics with slots don't work with Vue 2.7
Browse files Browse the repository at this point in the history
close #3241
  • Loading branch information
johnsoncodehk committed May 13, 2024
1 parent 2548ebf commit b267241
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
10 changes: 7 additions & 3 deletions packages/language-core/lib/codegen/script/globalTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ export function generateGlobalTypes(vueCompilerOptions: VueCompilerOptions) {
return `export const __VLS_globalTypesStart = {};
declare global {
// @ts-ignore
type __VLS_IntrinsicElements = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.IntrinsicElements, __VLS_PickNotAny<globalThis.JSX.IntrinsicElements, Record<string, any>>>;
type __VLS_IntrinsicElements = __VLS_PickNotAny<import('${vueCompilerOptions.lib}/jsx-runtime').JSX.IntrinsicElements, __VLS_PickNotAny<globalThis.JSX.IntrinsicElements, Record<string, any>>>;
// @ts-ignore
type __VLS_Element = __VLS_PickNotAny<import('vue/jsx-runtime').JSX.Element, globalThis.JSX.Element>;
type __VLS_Element = __VLS_PickNotAny<import('${vueCompilerOptions.lib}/jsx-runtime').JSX.Element, globalThis.JSX.Element>;
// @ts-ignore
type __VLS_GlobalComponents = ${[
`__VLS_PickNotAny<import('vue').GlobalComponents, {}>`,
`__VLS_PickNotAny<import('${vueCompilerOptions.lib}').GlobalComponents, {}>`,
`__VLS_PickNotAny<import('@vue/runtime-core').GlobalComponents, {}>`,
`__VLS_PickNotAny<import('@vue/runtime-dom').GlobalComponents, {}>`,
`Pick<typeof import('${vueCompilerOptions.lib}'), 'Transition' | 'TransitionGroup' | 'KeepAlive' | 'Suspense' | 'Teleport'>`
].join(' & ')};
type __VLS_BuiltInPublicProps =
__VLS_PickNotAny<import('${vueCompilerOptions.lib}').VNodeProps, {}>
& __VLS_PickNotAny<import('${vueCompilerOptions.lib}').AllowedComponentProps, {}>
& __VLS_PickNotAny<import('${vueCompilerOptions.lib}').ComponentCustomProps, {}>;
type __VLS_IsAny<T> = 0 extends 1 & T ? true : false;
type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
Expand Down
5 changes: 0 additions & 5 deletions packages/language-core/lib/codegen/script/scriptSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,6 @@ function* generateComponentProps(
yield `${ctx.helperTypes.OmitKeepDiscriminatedUnion.name}<InstanceType<typeof __VLS_fnComponent>['$props'], keyof __VLS_BuiltInPublicProps>`;
yield endOfLine;

yield `type __VLS_BuiltInPublicProps =${newLine}`
+ ` import('${options.vueCompilerOptions.lib}').VNodeProps${newLine}`
+ ` & import('${options.vueCompilerOptions.lib}').AllowedComponentProps${newLine}`
+ ` & import('${options.vueCompilerOptions.lib}').ComponentCustomProps${endOfLine}`;

if (scriptSetupRanges.defineProp.length) {
yield `const __VLS_defaults = {${newLine}`;
for (const defineProp of scriptSetupRanges.defineProp) {
Expand Down
1 change: 0 additions & 1 deletion test-workspace/tsc/vue2/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"../vue3",
],
"exclude": [
"../vue3/#2639",
"../vue3/#2700",
"../vue3/#3123",
"../vue3/#3289",
Expand Down

0 comments on commit b267241

Please sign in to comment.