Skip to content

Commit cc78c5f

Browse files
so1vejohnsoncodehk
andauthored
fix: generic components should respect strictTemplates (#3487)
Co-authored-by: Johnson Chu <[email protected]>
1 parent e9d1f3e commit cc78c5f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

packages/vue-language-core/src/generators/template.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,16 @@ export function generate(
743743
: dynamicTagExp ? ['', 'template', startTagOffset, capabilitiesPresets.diagnosticOnly]
744744
: '',
745745
'{ ',
746-
...createPropsCode(node, props, 'normal', propsFailedExps),
746+
);
747+
if (!vueCompilerOptions.strictTemplates) {
748+
// fix https://github.com/vuejs/language-tools/issues/3318
749+
codes.push('...{ ');
750+
}
751+
codes.push(...createPropsCode(node, props, 'normal', propsFailedExps));
752+
if (!vueCompilerOptions.strictTemplates) {
753+
codes.push('}, ');
754+
}
755+
codes.push(
747756
'}',
748757
// diagnostic end
749758
tagOffsets.length ? ['', 'template', tagOffsets[0] + tag.length, capabilitiesPresets.diagnosticOnly]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<script setup lang="ts" generic="T"></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 Comp from './Comp.vue';
3+
</script>
4+
5+
<template>
6+
<Comp id="id" />
7+
</template>

0 commit comments

Comments
 (0)