Skip to content

Commit baa1319

Browse files
authored
fix(language-core): intersect props of generic component with attrs (#4886)
1 parent 79dd4ab commit baa1319

File tree

5 files changed

+28
-5
lines changed

5 files changed

+28
-5
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function* generateScriptSetup(
6868
}
6969

7070
yield ` return {} as {${newLine}`
71-
+ ` props: ${ctx.localTypes.PrettifyLocal}<typeof __VLS_functionalComponentProps & __VLS_PublicProps> & __VLS_BuiltInPublicProps,${newLine}`
71+
+ ` props: ${ctx.localTypes.PrettifyLocal}<typeof __VLS_functionalComponentProps & __VLS_TemplateResult['attrs'] & __VLS_PublicProps> & __VLS_BuiltInPublicProps,${newLine}`
7272
+ ` expose(exposed: import('${options.vueCompilerOptions.lib}').ShallowUnwrapRef<${scriptSetupRanges.expose.define ? 'typeof __VLS_exposed' : '{}'}>): void,${newLine}`
7373
+ ` attrs: any,${newLine}`
7474
+ ` slots: __VLS_TemplateResult['slots'],${newLine}`

packages/tsc/tests/__snapshots__/dts.spec.ts.snap

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`vue-tsc-dts > Input: #4577/main.vue, Output: #4577/main.vue.d.ts 1`] =
55
value: string;
66
};
77
declare const _default: <Row extends BaseRow>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
8-
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & {
8+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & Partial<{}> & {
99
nonGeneric: string;
1010
rows: Row[];
1111
}> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
@@ -71,7 +71,7 @@ exports[`vue-tsc-dts > Input: events/component-generic.vue, Output: events/compo
7171
"declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
7272
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
7373
readonly onFoo?: (value: string) => any;
74-
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onFoo"> & {}> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
74+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onFoo"> & Partial<{}> & {}> & (import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
7575
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
7676
attrs: any;
7777
slots: {};
@@ -93,7 +93,7 @@ exports[`vue-tsc-dts > Input: generic/component.vue, Output: generic/component.v
9393
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
9494
readonly "onUpdate:title"?: (title: string) => any;
9595
readonly onBar?: (data: number) => any;
96-
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onUpdate:title" | "onBar"> & ({
96+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onUpdate:title" | "onBar"> & Partial<{}> & ({
9797
title?: string;
9898
} & {
9999
foo: number;
@@ -129,7 +129,7 @@ exports[`vue-tsc-dts > Input: generic/custom-extension-component.cext, Output: g
129129
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
130130
readonly "onUpdate:title"?: (title: string) => any;
131131
readonly onBar?: (data: number) => any;
132-
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onUpdate:title" | "onBar"> & ({
132+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onUpdate:title" | "onBar"> & Partial<{}> & ({
133133
title?: string;
134134
} & {
135135
foo: number;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<script setup lang="ts" generic="T">
2+
import child from './child.vue';
3+
4+
defineProps<{
5+
foo?: T;
6+
}>();
7+
</script>
8+
9+
<template>
10+
<child />
11+
</template>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script setup lang="ts">
2+
defineProps<{
3+
bar?: string;
4+
}>();
5+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script setup lang="ts">
2+
import basic from './basic.vue';
3+
</script>
4+
5+
<template>
6+
<basic bar="..."/>
7+
</template>

0 commit comments

Comments
 (0)