Skip to content

Commit b2707f0

Browse files
committed
fix(language-core): fallthrough attributes should be optional
1 parent 29b13cf commit b2707f0

File tree

6 files changed

+28
-9
lines changed

6 files changed

+28
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ function* generateTemplateContext(
158158
yield `return {${newLine}`;
159159
yield `slots: ${options.scriptSetupRanges?.slots.name ?? '__VLS_slots'},${newLine}`;
160160
yield `refs: __VLS_refs as __VLS_PickRefsExpose<typeof __VLS_refs>,${newLine}`;
161-
yield `attrs: __VLS_inheritedAttrs,${newLine}`;
161+
yield `attrs: {} as Partial<typeof __VLS_inheritedAttrs>,${newLine}`;
162162
yield `}${endOfLine}`;
163163
}
164164

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,17 @@ type __VLS_Prettify<T> = {
170170
`;
171171
172172
exports[`vue-tsc-dts > Input: generic/main.vue, Output: generic/main.vue.d.ts 1`] = `
173-
"declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_OmitIndexSignature<{
173+
"declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_OmitIndexSignature<Partial<{
174174
"onUpdate:title"?: (title: string) => any;
175175
onBar?: (data: number) => any;
176176
title?: string;
177177
foo: number;
178-
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_OmitIndexSignature<{
178+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps>>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_OmitIndexSignature<Partial<{
179179
"onUpdate:title"?: (title: string) => any;
180180
onBar?: (data: number) => any;
181181
title?: string;
182182
foo: number;
183-
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps>>>>, {}, {}>;
183+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps>>>>>, {}, {}>;
184184
export default _default;
185185
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
186186
type __VLS_TypePropsToOption<T> = {
@@ -671,7 +671,7 @@ exports[`vue-tsc-dts > Input: template-slots/component.vue, Output: template-slo
671671
}): any;
672672
};
673673
refs: __VLS_PickRefsExpose<{}>;
674-
attrs: {};
674+
attrs: Partial<{}>;
675675
};
676676
type __VLS_Slots = ReturnType<typeof __VLS_template>['slots'];
677677
declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
@@ -714,7 +714,7 @@ declare const __VLS_template: () => {
714714
'no-bind': () => VNode[];
715715
};
716716
refs: __VLS_PickRefsExpose<{}>;
717-
attrs: {};
717+
attrs: Partial<{}>;
718718
};
719719
type __VLS_Slots = ReturnType<typeof __VLS_template>['slots'];
720720
declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
@@ -740,7 +740,7 @@ exports[`vue-tsc-dts > Input: template-slots/component-destructuring.vue, Output
740740
}) => any[];
741741
};
742742
refs: __VLS_PickRefsExpose<{}>;
743-
attrs: {};
743+
attrs: Partial<{}>;
744744
};
745745
type __VLS_Slots = ReturnType<typeof __VLS_template>['slots'];
746746
declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
@@ -770,7 +770,7 @@ exports[`vue-tsc-dts > Input: template-slots/component-no-script.vue, Output: te
770770
}): any;
771771
};
772772
refs: __VLS_PickRefsExpose<{}>;
773-
attrs: {};
773+
attrs: Partial<{}>;
774774
};
775775
type __VLS_Slots = ReturnType<typeof __VLS_template>['slots'];
776776
declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;

test-workspace/tsc/passedFixtures/vue3_strictTemplate/inheritAttrs/main.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script setup lang="ts">
1+
<script setup lang="ts">
22
import { exactType } from '../../shared';
33
import basic from './basic.vue';
44
import inheritAttrsFalse from './inherit-attrs-false.vue';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script setup lang="ts">
2+
import child from './child.vue';
3+
</script>
4+
5+
<template>
6+
<child bar="bar" />
7+
</template>
Lines changed: 5 additions & 0 deletions
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>
Lines changed: 7 additions & 0 deletions
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 />
7+
</template>

0 commit comments

Comments
 (0)