Skip to content

Commit

Permalink
test(tsc): test all typecheck cases in one tsconfig (#4723)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk authored Aug 25, 2024
1 parent 0020c08 commit 0b99c60
Show file tree
Hide file tree
Showing 269 changed files with 137 additions and 181 deletions.
2 changes: 1 addition & 1 deletion packages/component-meta/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ const tsconfigChecker = createChecker(
const noTsConfigChecker = createCheckerByJson(
path.resolve(__dirname, '../../../test-workspace/component-meta'),
{
"extends": "../tsconfig.json",
"extends": "../tsconfig.base.json",
"include": [
"**/*",
],
Expand Down
4 changes: 2 additions & 2 deletions packages/tsc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import * as vue from '@vue/language-core';

const windowsPathReg = /\\/g;

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

let runExtensions = ['.vue'];

const extensionsChangedException = new Error('extensions changed');
const main = () => runTsc(
require.resolve('typescript/lib/tsc'),
tscPath,
runExtensions,
(ts, options) => {
const { configFilePath } = options.options;
Expand Down
97 changes: 0 additions & 97 deletions packages/tsc/tests/index.spec.ts

This file was deleted.

35 changes: 35 additions & 0 deletions packages/tsc/tests/typecheck.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as path from 'path';
import { describe, expect, it } from 'vitest';
import { run } from '..';

describe(`vue-tsc`, () => {

it(`typecheck`, async () => {
const consoleOutput: string[] = [];
const originalConsoleLog = process.stdout.write;
const originalArgv = process.argv;
process.stdout.write = output => {
consoleOutput.push(String(output).trim());
return true;
};
process.argv = [
...originalArgv,
'--build',
path.resolve(__dirname, '../../../test-workspace/tsc'),
'--pretty',
'false',
];
try {
run();
} catch (err) { }
process.stdout.write = originalConsoleLog;
process.argv = originalArgv;
expect(consoleOutput).toMatchInlineSnapshot(`
[
"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 ..., {}>'.",
"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 ..., {}>'.",
"test-workspace/tsc/failureFixtures/directives/main.vue(12,2): error TS2578: Unused '@ts-expect-error' directive.",
]
`);;
});
});
2 changes: 1 addition & 1 deletion test-workspace/component-meta/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../tsconfig.base.json",
"include": [
"**/*",
],
Expand Down
4 changes: 0 additions & 4 deletions test-workspace/tsc/#1886/tsconfig.json

This file was deleted.

4 changes: 0 additions & 4 deletions test-workspace/tsc/#2157/tsconfig.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"include": [ "**/*" ],
"compilerOptions": {
"noEmit": false,
Expand Down
18 changes: 18 additions & 0 deletions test-workspace/tsc/failureFixtures/directives/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<!-- @vue-ignore -->
<div v-if="true">
{{ notExist }}
</div>

<!-- @vue-ignore -->
<div v-for="_a in 10" :foo="notExist">
{{ notExist }}
</div>

<!-- @vue-expect-error -->
<div v-bind="exist"></div>
</template>

<script setup lang="ts">
const exist = {};
</script>
4 changes: 4 additions & 0 deletions test-workspace/tsc/failureFixtures/directives/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../../tsconfig.base.json",
"include": [ "**/*" ]
}
File renamed without changes.
4 changes: 4 additions & 0 deletions test-workspace/tsc/passedFixtures/#1886/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../../tsconfig.base.json",
"include": [ "**/*" ]
}
File renamed without changes.
4 changes: 4 additions & 0 deletions test-workspace/tsc/passedFixtures/#2157/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../../tsconfig.base.json",
"include": [ "**/*" ]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"vueCompilerOptions": {
"jsxSlots": true
},
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"importsNotUsedAsValues": "error",
"ignoreDeprecations": "5.0"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"include": [ "**/*" ],
"compilerOptions": {
"noPropertyAccessFromIndexSignature": false
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"include": ["**/*"],
"compilerOptions": {
"checkJs": true
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"include": [ "**/*" ],
"vueCompilerOptions": {
"experimentalResolveStyleCssClasses": "always",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"include": [ "**/*" ],
"compilerOptions": {
"strict": false,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"include": [ "**/*" ],
"compilerOptions": {
"checkJs": true,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"jsxImportSource": "none",
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"noPropertyAccessFromIndexSignature": true,
},
Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions test-workspace/tsc/passedFixtures/pug/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.base.json",
"include": [
"**/*"
],
"vueCompilerOptions": {
"plugins": [
"../../../../packages/language-plugin-pug"
]
},
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"vueCompilerOptions": {
"target": 2.7,
},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"vueCompilerOptions": {
"target": 3.3,
},
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"vueCompilerOptions": {
"target": 3.5,
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { exactType } from 'tsc/shared';
import { exactType } from '../../shared';
declare const Child: undefined | (new () => {
$props: {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { exactType } from 'tsc/shared';
import { exactType } from '../../shared';
const { bottom } = defineSlots<{
bottom: (props: { num: number; }) => any[],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</template>

<script setup lang="ts">
import { exactType } from 'tsc/shared';
import { exactType } from '../../shared';
import { ref } from 'vue';
const msg = ref('Hello Vue 3 + TypeScript + Vite');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>{{ msg }}</template>

<script lang="ts" setup>
import {exactType} from 'tsc/shared'
import { exactType } from '../../shared';
import {PropType} from 'vue'
const msg = defineModel('msg', {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<child2 v-model:other="other" />
</template>
<script lang="ts" setup>
import { exactType } from 'tsc/shared'
import { exactType } from '../../shared';
import { ref } from 'vue'
import child from './child.vue'
import child2 from './child2.vue'
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</Child>
</template>
<script lang="ts" setup>
import { exactType } from 'tsc/shared'
import { exactType } from '../../shared';
import Child from './child.vue'
const n = 1 as const
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="tsx">
import { exactType } from 'tsc/shared';
import { exactType } from '../../shared';
defineOptions({
name: 'Foo',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../tsconfig.base.json",
"include": [
"**/*",
],
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { exactType } from "tsc/shared";
import { exactType } from '../../shared';
interface Props {
actionText?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../../tsconfig.base.json",
"vueCompilerOptions": {
"strictTemplates": true
},
Expand Down
Loading

0 comments on commit 0b99c60

Please sign in to comment.