Skip to content

Commit bc8521e

Browse files
committed
fix(tsc): TS4082 not reported for functional component
close #4569
1 parent c0ec60a commit bc8521e

File tree

6 files changed

+41
-2
lines changed

6 files changed

+41
-2
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,19 @@ export function* generateScript(options: ScriptCodegenOptions): Generator<Code>
125125
yield* generateDefineProp(options, options.sfc.scriptSetup);
126126
yield* generateScriptSetup(options, ctx, options.sfc.scriptSetup, options.scriptSetupRanges);
127127
}
128-
yield endOfLine;
128+
129+
yield `;`;
130+
if (options.sfc.scriptSetup) {
131+
// #4569
132+
yield [
133+
'',
134+
'scriptSetup',
135+
options.sfc.scriptSetup.content.length,
136+
codeFeatures.verification,
137+
];
138+
}
139+
yield newLine;
140+
129141
if (options.globalTypes) {
130142
yield generateGlobalTypes(options.vueCompilerOptions);
131143
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ export function* generateScriptSetup(
2929

3030
if (scriptSetup.generic) {
3131
if (!options.scriptRanges?.exportDefault) {
32+
if (options.sfc.scriptSetup) {
33+
// #4569
34+
yield [
35+
'',
36+
'scriptSetup',
37+
options.sfc.scriptSetup.content.length,
38+
codeFeatures.verification,
39+
];
40+
}
3241
yield `export default `;
3342
}
3443
yield `(<`;

packages/tsc/tests/index.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const shouldErrorDirs = [
99
'should-error',
1010
'should-error-2',
1111
'should-error-3',
12+
'should-error-#4569',
1213
];
1314

1415
function prettyPath(path: string, isRoot: boolean) {
@@ -52,7 +53,7 @@ function runVueTsc(cwd: string) {
5253
return new Promise((resolve, reject) => {
5354
const cp = fork(
5455
binPath,
55-
['--noEmit'],
56+
[],
5657
{
5758
silent: true,
5859
cwd
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<script lang="ts" setup generic="TItem">
2+
interface Props {
3+
item: any;
4+
}
5+
6+
defineProps<Props>();
7+
</script>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"include": [ "**/*" ],
4+
"compilerOptions": {
5+
"noEmit": false,
6+
"emitDeclarationOnly": true,
7+
"declaration": true,
8+
}
9+
}

test-workspace/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"noUnusedParameters": true,
1111
"skipLibCheck": true,
1212
"allowJs": true,
13+
"noEmit": true,
1314
"jsx": "preserve",
1415
"baseUrl": ".",
1516
},

0 commit comments

Comments
 (0)