Skip to content

Commit dbe8b53

Browse files
authored
fix(language-core): use component instance props as fallthrough attributes (#5686)
1 parent 5080fd9 commit dbe8b53

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ export function* generateComponent(
265265

266266
if (hasVBindAttrs(options, ctx, node)) {
267267
const attrsVar = ctx.getInternalVariable();
268-
yield `var ${attrsVar}!: Parameters<typeof ${componentFunctionalVar}>[0]${endOfLine}`;
268+
ctx.currentComponent.used = true;
269+
270+
yield `var ${attrsVar}!: NonNullable<typeof ${componentCtxVar}['props']>${endOfLine}`;
269271
ctx.inheritedAttrVars.add(attrsVar);
270272
}
271273

test-workspace/tsc/passedFixtures/fallthroughAttributes_strictTemplate/generic/basic.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import child from './child.vue';
33
44
defineProps<{
5-
foo?: T;
5+
bar?: T;
66
}>();
77
</script>
88

99
<template>
10-
<child />
10+
<child :foo="bar" />
1111
</template>
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
<script setup lang="ts">
1+
<script setup lang="ts" generic="T">
22
defineProps<{
3-
bar?: string;
3+
foo?: T;
4+
}>();
5+
defineEmits<{
6+
foo: [T];
47
}>();
58
</script>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import { exactType } from '../../shared';
23
import basic from './basic.vue';
34
</script>
45

56
<template>
6-
<basic bar="..."/>
7+
<basic bar="..." @foo="e => exactType(e, {} as string)"/>
78
</template>

0 commit comments

Comments
 (0)