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

+1-1
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

+2-2
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

-97
This file was deleted.

packages/tsc/tests/typecheck.spec.ts

+35
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

+1-1
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

-4
This file was deleted.

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

-4
This file was deleted.

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

+1-1
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,
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>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../../tsconfig.base.json",
3+
"include": [ "**/*" ]
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../../tsconfig.base.json",
3+
"include": [ "**/*" ]
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "../../../tsconfig.base.json",
3+
"include": [ "**/*" ]
4+
}

test-workspace/tsc/#2472/tsconfig.json test-workspace/tsc/passedFixtures/#2472/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.base.json",
33
"vueCompilerOptions": {
44
"jsxSlots": true
55
},

test-workspace/tsc/#3373/tsconfig.json test-workspace/tsc/passedFixtures/#3373/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.base.json",
33
"compilerOptions": {
44
"importsNotUsedAsValues": "error",
55
"ignoreDeprecations": "5.0"

test-workspace/tsc/#3574/tsconfig.json test-workspace/tsc/passedFixtures/#3574/tsconfig.json

+1-1
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
"noPropertyAccessFromIndexSignature": false

test-workspace/tsc/#3592/tsconfig.json test-workspace/tsc/passedFixtures/#3592/tsconfig.json

+1-1
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
"checkJs": true

test-workspace/tsc/#3688/tsconfig.json test-workspace/tsc/passedFixtures/#3688/tsconfig.json

+1-1
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
"vueCompilerOptions": {
55
"experimentalResolveStyleCssClasses": "always",

test-workspace/tsc/#3819/tsconfig.json test-workspace/tsc/passedFixtures/#3819/tsconfig.json

+1-1
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
"strict": false,

test-workspace/tsc/#4503/tsconfig.json test-workspace/tsc/passedFixtures/#4503/tsconfig.json

+1-1
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
"checkJs": true,

test-workspace/tsc/core#9923/tsconfig.json test-workspace/tsc/passedFixtures/core#9923/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.base.json",
33
"compilerOptions": {
44
"jsxImportSource": "none",
55
},

test-workspace/tsc/noPropertyAccessFromIndexSignature/tsconfig.json test-workspace/tsc/passedFixtures/noPropertyAccessFromIndexSignature/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.base.json",
33
"compilerOptions": {
44
"noPropertyAccessFromIndexSignature": true,
55
},
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../../../tsconfig.base.json",
3+
"include": [
4+
"**/*"
5+
],
6+
"vueCompilerOptions": {
7+
"plugins": [
8+
"../../../../packages/language-plugin-pug"
9+
]
10+
},
11+
}
File renamed without changes.

test-workspace/tsc/vue2/tsconfig.json test-workspace/tsc/passedFixtures/vue2/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.base.json",
33
"vueCompilerOptions": {
44
"target": 2.7,
55
},

test-workspace/tsc/vue3.3/tsconfig.json test-workspace/tsc/passedFixtures/vue3.3/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.base.json",
33
"vueCompilerOptions": {
44
"target": 3.3,
55
},

test-workspace/tsc/vue3.5/tsconfig.json test-workspace/tsc/passedFixtures/vue3.5/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.base.json",
33
"vueCompilerOptions": {
44
"target": 3.5,
55
},

test-workspace/tsc/vue3/#3138/main.vue test-workspace/tsc/passedFixtures/vue3/#3138/main.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { exactType } from 'tsc/shared';
2+
import { exactType } from '../../shared';
33
44
declare const Child: undefined | (new () => {
55
$props: {

test-workspace/tsc/vue3/#4326/main.vue test-workspace/tsc/passedFixtures/vue3/#4326/main.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { exactType } from 'tsc/shared';
2+
import { exactType } from '../../shared';
33
44
const { bottom } = defineSlots<{
55
bottom: (props: { num: number; }) => any[],

test-workspace/tsc/vue3/#4604/main.vue test-workspace/tsc/passedFixtures/vue3/#4604/main.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</template>
88

99
<script setup lang="ts">
10-
import { exactType } from 'tsc/shared';
10+
import { exactType } from '../../shared';
1111
import { ref } from 'vue';
1212
1313
const msg = ref('Hello Vue 3 + TypeScript + Vite');

test-workspace/tsc/vue3/#4646/child.vue test-workspace/tsc/passedFixtures/vue3/#4646/child.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>{{ msg }}</template>
22

33
<script lang="ts" setup>
4-
import {exactType} from 'tsc/shared'
4+
import { exactType } from '../../shared';
55
import {PropType} from 'vue'
66
77
const msg = defineModel('msg', {

test-workspace/tsc/vue3/#4646/parent.vue test-workspace/tsc/passedFixtures/vue3/#4646/parent.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<child2 v-model:other="other" />
66
</template>
77
<script lang="ts" setup>
8-
import { exactType } from 'tsc/shared'
8+
import { exactType } from '../../shared';
99
import { ref } from 'vue'
1010
import child from './child.vue'
1111
import child2 from './child2.vue'

test-workspace/tsc/vue3/#4668/main.vue test-workspace/tsc/passedFixtures/vue3/#4668/main.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</Child>
1010
</template>
1111
<script lang="ts" setup>
12-
import { exactType } from 'tsc/shared'
12+
import { exactType } from '../../shared';
1313
import Child from './child.vue'
1414
1515
const n = 1 as const

test-workspace/tsc/vue3/defineOptions/child.vue test-workspace/tsc/passedFixtures/vue3/defineOptions/child.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="tsx">
2-
import { exactType } from 'tsc/shared';
2+
import { exactType } from '../../shared';
33
44
defineOptions({
55
name: 'Foo',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../../../tsconfig.base.json",
3+
"include": [
4+
"**/*",
5+
],
6+
}

test-workspace/tsc/vue3/withDefaults/main.vue test-workspace/tsc/passedFixtures/vue3/withDefaults/main.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { exactType } from "tsc/shared";
2+
import { exactType } from '../../shared';
33
44
interface Props {
55
actionText?: string;

test-workspace/tsc/vue3_strictTemplate/tsconfig.json test-workspace/tsc/passedFixtures/vue3_strictTemplate/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.base.json",
33
"vueCompilerOptions": {
44
"strictTemplates": true
55
},

0 commit comments

Comments
 (0)