Skip to content

Commit 0b99c60

Browse files
test(tsc): test all typecheck cases in one tsconfig (#4723)
1 parent 0020c08 commit 0b99c60

File tree

269 files changed

+137
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

269 files changed

+137
-181
lines changed

packages/component-meta/tests/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ const tsconfigChecker = createChecker(
863863
const noTsConfigChecker = createCheckerByJson(
864864
path.resolve(__dirname, '../../../test-workspace/component-meta'),
865865
{
866-
"extends": "../tsconfig.json",
866+
"extends": "../tsconfig.base.json",
867867
"include": [
868868
"**/*",
869869
],

packages/tsc/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import * as vue from '@vue/language-core';
33

44
const windowsPathReg = /\\/g;
55

6-
export function run() {
6+
export function run(tscPath = require.resolve('typescript/lib/tsc')) {
77

88
let runExtensions = ['.vue'];
99

1010
const extensionsChangedException = new Error('extensions changed');
1111
const main = () => runTsc(
12-
require.resolve('typescript/lib/tsc'),
12+
tscPath,
1313
runExtensions,
1414
(ts, options) => {
1515
const { configFilePath } = options.options;

packages/tsc/tests/index.spec.ts

Lines changed: 0 additions & 97 deletions
This file was deleted.

packages/tsc/tests/typecheck.spec.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import * as path from 'path';
2+
import { describe, expect, it } from 'vitest';
3+
import { run } from '..';
4+
5+
describe(`vue-tsc`, () => {
6+
7+
it(`typecheck`, async () => {
8+
const consoleOutput: string[] = [];
9+
const originalConsoleLog = process.stdout.write;
10+
const originalArgv = process.argv;
11+
process.stdout.write = output => {
12+
consoleOutput.push(String(output).trim());
13+
return true;
14+
};
15+
process.argv = [
16+
...originalArgv,
17+
'--build',
18+
path.resolve(__dirname, '../../../test-workspace/tsc'),
19+
'--pretty',
20+
'false',
21+
];
22+
try {
23+
run();
24+
} catch (err) { }
25+
process.stdout.write = originalConsoleLog;
26+
process.argv = originalArgv;
27+
expect(consoleOutput).toMatchInlineSnapshot(`
28+
[
29+
"test-workspace/tsc/failureFixtures/directives/main.vue(4,6): error TS2339: Property 'notExist' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { exist: typeof exist; }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 12 more ..., {}>'.",
30+
"test-workspace/tsc/failureFixtures/directives/main.vue(9,6): error TS2339: Property 'notExist' does not exist on type 'CreateComponentPublicInstance<Readonly<ExtractPropTypes<{}>>, { exist: typeof exist; }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ... 12 more ..., {}>'.",
31+
"test-workspace/tsc/failureFixtures/directives/main.vue(12,2): error TS2578: Unused '@ts-expect-error' directive.",
32+
]
33+
`);;
34+
});
35+
});

test-workspace/component-meta/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../tsconfig.json",
2+
"extends": "../tsconfig.base.json",
33
"include": [
44
"**/*",
55
],

test-workspace/tsc/#1886/tsconfig.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

test-workspace/tsc/#2157/tsconfig.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

test-workspace/tsc/should-error-#4569/tsconfig.json renamed to test-workspace/tsc/failureFixtures/#4569/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.base.json",
33
"include": [ "**/*" ],
44
"compilerOptions": {
55
"noEmit": false,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<!-- @vue-ignore -->
3+
<div v-if="true">
4+
{{ notExist }}
5+
</div>
6+
7+
<!-- @vue-ignore -->
8+
<div v-for="_a in 10" :foo="notExist">
9+
{{ notExist }}
10+
</div>
11+
12+
<!-- @vue-expect-error -->
13+
<div v-bind="exist"></div>
14+
</template>
15+
16+
<script setup lang="ts">
17+
const exist = {};
18+
</script>

0 commit comments

Comments
 (0)