|
1 | 1 | import * as path from 'path';
|
2 |
| -import { describe, expect, it } from 'vitest'; |
| 2 | +import { describe, expect, test } from 'vitest'; |
3 | 3 | import { run } from '..';
|
4 | 4 |
|
5 | 5 | describe(`vue-tsc`, () => {
|
6 | 6 |
|
7 |
| - it(`typecheck`, () => { |
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(` |
| 7 | + test(`TypeScript - Stable`, () => { |
| 8 | + expect( |
| 9 | + getTscOutput('stable') |
| 10 | + ).toMatchInlineSnapshot(` |
28 | 11 | [
|
29 | 12 | "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 | 13 | "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 | 14 | "test-workspace/tsc/failureFixtures/directives/main.vue(12,2): error TS2578: Unused '@ts-expect-error' directive.",
|
32 | 15 | ]
|
33 |
| - `);; |
| 16 | + `); |
| 17 | + }); |
| 18 | + |
| 19 | + test(`TypeScript - next`, () => { |
| 20 | + expect( |
| 21 | + getTscOutput('next') |
| 22 | + ).toMatchInlineSnapshot(` |
| 23 | + [ |
| 24 | + "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 ..., {}>'.", |
| 25 | + "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 ..., {}>'.", |
| 26 | + "test-workspace/tsc/failureFixtures/directives/main.vue(12,2): error TS2578: Unused '@ts-expect-error' directive.", |
| 27 | + "test-workspace/tsc/passedFixtures/#3373/tsconfig.json(4,3): error TS5102: Option 'importsNotUsedAsValues' has been removed. Please remove it from your configuration. |
| 28 | + Use 'verbatimModuleSyntax' instead.", |
| 29 | + ] |
| 30 | + `); |
34 | 31 | });
|
35 | 32 | });
|
| 33 | + |
| 34 | +function getTscOutput(tsVersion) { |
| 35 | + const consoleOutput: string[] = []; |
| 36 | + const originalConsoleLog = process.stdout.write; |
| 37 | + const originalArgv = process.argv; |
| 38 | + process.stdout.write = output => { |
| 39 | + consoleOutput.push(String(output).trim()); |
| 40 | + return true; |
| 41 | + }; |
| 42 | + process.argv = [ |
| 43 | + ...originalArgv, |
| 44 | + '--build', |
| 45 | + path.resolve(__dirname, '../../../test-workspace/tsc'), |
| 46 | + '--pretty', |
| 47 | + 'false', |
| 48 | + ]; |
| 49 | + try { |
| 50 | + const tscPath = require.resolve( |
| 51 | + `typescript-${tsVersion}/lib/tsc`, |
| 52 | + { paths: [path.resolve(__dirname, '../../../test-workspace')] } |
| 53 | + ); |
| 54 | + run(tscPath); |
| 55 | + } catch (err) { } |
| 56 | + process.stdout.write = originalConsoleLog; |
| 57 | + process.argv = originalArgv; |
| 58 | + return consoleOutput; |
| 59 | +} |
0 commit comments