|
| 1 | +import { jsonToReadableText } from "../helpers.js"; |
| 2 | +import { |
| 3 | + noChangeRun, |
| 4 | + TestTscEdit, |
| 5 | + verifyTsc, |
| 6 | +} from "./tsc.js"; |
| 7 | +import { loadProjectFromFiles } from "./vfs.js"; |
| 8 | + |
| 9 | +export function forEachTscScenarioWithNoCheck(buildType: "-b" | "-p") { |
| 10 | + const commandLineArgs = buildType === "-b" ? |
| 11 | + ["-b", "/src/tsconfig.json", "-v"] : |
| 12 | + ["-p", "/src/tsconfig.json"]; |
| 13 | + |
| 14 | + function forEachNoCheckScenarioWorker( |
| 15 | + subScenario: string, |
| 16 | + aText: string, |
| 17 | + ) { |
| 18 | + const checkNoChangeRun: TestTscEdit = { |
| 19 | + ...noChangeRun, |
| 20 | + caption: "No Change run with checking", |
| 21 | + commandLineArgs, |
| 22 | + }; |
| 23 | + const noCheckFixError: TestTscEdit = { |
| 24 | + caption: "Fix `a` error with noCheck", |
| 25 | + edit: fs => fs.writeFileSync("/src/a.ts", `export const a = "hello";`), |
| 26 | + }; |
| 27 | + const noCheckError: TestTscEdit = { |
| 28 | + caption: "Introduce error with noCheck", |
| 29 | + edit: fs => fs.writeFileSync("/src/a.ts", aText), |
| 30 | + }; |
| 31 | + |
| 32 | + [undefined, true].forEach(incremental => { |
| 33 | + [{}, { module: "amd", outFile: "../outFile.js" }].forEach(options => { |
| 34 | + verifyTsc({ |
| 35 | + scenario: "noCheck", |
| 36 | + subScenario: `${options.outFile ? "outFile" : "multiFile"}/${subScenario}${incremental ? " with incremental" : ""}`, |
| 37 | + fs: () => |
| 38 | + loadProjectFromFiles({ |
| 39 | + "/src/a.ts": aText, |
| 40 | + "/src/b.ts": `export const b = 10;`, |
| 41 | + "/src/tsconfig.json": jsonToReadableText({ |
| 42 | + compilerOptions: { |
| 43 | + declaration: true, |
| 44 | + incremental, |
| 45 | + ...options, |
| 46 | + }, |
| 47 | + }), |
| 48 | + }), |
| 49 | + commandLineArgs: [...commandLineArgs, "--noCheck"], |
| 50 | + edits: [ |
| 51 | + noChangeRun, // Should be no op |
| 52 | + noCheckFixError, // Fix error with noCheck |
| 53 | + noChangeRun, // Should be no op |
| 54 | + checkNoChangeRun, // Check errors - should not report any errors - update buildInfo |
| 55 | + checkNoChangeRun, // Should be no op |
| 56 | + noChangeRun, // Should be no op |
| 57 | + noCheckError, |
| 58 | + noChangeRun, // Should be no op |
| 59 | + checkNoChangeRun, // Should check errors and update buildInfo |
| 60 | + noCheckFixError, // Fix error with noCheck |
| 61 | + checkNoChangeRun, // Should check errors and update buildInfo |
| 62 | + { |
| 63 | + caption: "Add file with error", |
| 64 | + edit: fs => fs.writeFileSync("/src/c.ts", `export const c: number = "hello";`), |
| 65 | + commandLineArgs, |
| 66 | + }, |
| 67 | + noCheckError, |
| 68 | + noCheckFixError, |
| 69 | + checkNoChangeRun, |
| 70 | + noChangeRun, // Should be no op |
| 71 | + checkNoChangeRun, // Should be no op |
| 72 | + ], |
| 73 | + baselinePrograms: true, |
| 74 | + }); |
| 75 | + }); |
| 76 | + }); |
| 77 | + } |
| 78 | + forEachNoCheckScenarioWorker("syntax errors", `export const a = "hello`); |
| 79 | + forEachNoCheckScenarioWorker("semantic errors", `export const a: number = "hello";`); |
| 80 | + forEachNoCheckScenarioWorker("dts errors", `export const a = class { private p = 10; };`); |
| 81 | +} |
0 commit comments