Skip to content

Commit 55ca36f

Browse files
00200200KazariEX
andauthored
fix(language-core): keep inference-only props string single-line with block comments (#6230)
Co-authored-by: Amulet Kerria <[email protected]>
1 parent 7d2e603 commit 55ca36f

5 files changed

Lines changed: 34 additions & 1 deletion

File tree

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ export function* generateComponent(
195195
options.vueCompilerOptions.checkUnknownProps ? names.asFunctionalComponent0 : names.asFunctionalComponent1
196196
}(${componentVar}, new ${componentVar}({${newLine}`;
197197
yield `// @ts-ignore${newLine}`;
198-
yield propsStr.replace(/\n/g, ' ');
198+
yield propsStr
199+
.replace(/\/\/(.*)$/gm, (_, body) => `/*${body.replaceAll("*/", "*\\/")} */`)
200+
.replace(/\n/g, ' ');
199201
yield `}))${endOfLine}`;
200202

201203
yield `const `;

‎test-workspace/tsc/#6228/Child.vue‎

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+
foo: string;
4+
}>();
5+
</script>

‎test-workspace/tsc/#6228/main.vue‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script setup lang="ts">
2+
import Child from './Child.vue';
3+
</script>
4+
5+
<template>
6+
<Child
7+
:foo="
8+
// a comment
9+
'x'
10+
"
11+
/>
12+
<!-- @vue-expect-error -->
13+
<Child
14+
:foo="
15+
// a comment
16+
1
17+
"
18+
/>
19+
</template>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"include": ["**/*"]
4+
}

‎test-workspace/tsc/tsconfig.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@
529529
{
530530
"path": "./#6180/tsconfig.json"
531531
},
532+
{
533+
"path": "./#6228/tsconfig.json"
534+
},
532535
{
533536
"path": "./#625/tsconfig.json"
534537
},

0 commit comments

Comments
 (0)