From 4c378c09dcf8f14d36d6ea982ee45535cf75fdc3 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 30 Jan 2020 11:18:06 -0800 Subject: [PATCH] Report config file parsing diagnostics correctly with tsc --b (#36520) * Refactor the test * Add tests for syntax errors in tsconfig not being reported * Report config file parsing diagnostics correctly Fixes #36515 * Fix errors in existing tests for unintended tsconfig parse errors * Fix lint --- src/compiler/tsbuildPublic.ts | 14 +- src/testRunner/tsconfig.json | 2 +- .../unittests/tsbuild/configFileErrors.ts | 57 ++++ .../tsbuild/containerOnlyReferenced.ts | 11 +- .../tsbuild/javascriptProjectEmit.ts | 2 +- .../unittests/tsbuild/lateBoundSymbol.ts | 10 +- .../unittests/tsbuild/missingExtendedFile.ts | 17 -- .../unittests/tsbuild/noEmitOnError.ts | 9 +- src/testRunner/unittests/tsbuild/outFile.ts | 2 +- .../unittests/tsbuild/resolveJsonModule.ts | 11 +- src/testRunner/unittests/tsbuild/watchMode.ts | 65 +++- src/testRunner/unittests/tscWatch/helpers.ts | 5 + .../unittests/tscWatch/programUpdates.ts | 3 +- .../multiple-emitHelpers-in-all-projects.js | 2 +- .../multiple-prologues-in-all-projects.js | 2 +- .../initial-build/stripInternal.js | 2 +- .../builds-after-fixing-config-file-errors.js | 63 ++++ ...ntax-errors-after-change-to-config-file.js | 18 ++ ...s-syntax-errors-after-change-to-ts-file.js | 9 + .../reports-syntax-errors-in-config-file.js | 6 + .../when-tsconfig-extends-the-missing-file.js | 0 .../reports-syntax-errors-in-config-file.js | 6 + ...hen-internal-is-inside-another-internal.js | 2 +- ...en-one-two-three-are-prepended-in-order.js | 2 +- .../stripInternal-jsdoc-style-comment.js | 2 +- ...en-one-two-three-are-prepended-in-order.js | 2 +- ...-jsdoc-style-with-comments-emit-enabled.js | 2 +- ...l-when-few-members-of-enum-are-internal.js | 2 +- ...en-one-two-three-are-prepended-in-order.js | 2 +- ...en-one-two-three-are-prepended-in-order.js | 2 +- ...tripInternal-with-comments-emit-enabled.js | 2 +- .../initial-build/stripInternal.js | 2 +- .../reports-syntax-errors-in-config-file.js | 289 ++++++++++++++++++ .../amdModulesWithOut/app/tsconfig.json | 2 +- 34 files changed, 543 insertions(+), 84 deletions(-) create mode 100644 src/testRunner/unittests/tsbuild/configFileErrors.ts delete mode 100644 src/testRunner/unittests/tsbuild/missingExtendedFile.ts create mode 100644 tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-changes/builds-after-fixing-config-file-errors.js create mode 100644 tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-doesnt-change/reports-syntax-errors-after-change-to-config-file.js create mode 100644 tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-doesnt-change/reports-syntax-errors-after-change-to-ts-file.js create mode 100644 tests/baselines/reference/tsbuild/configFileErrors/initial-build/reports-syntax-errors-in-config-file.js rename tests/baselines/reference/tsbuild/{missingExtendedConfig => configFileErrors}/initial-build/when-tsconfig-extends-the-missing-file.js (100%) create mode 100644 tests/baselines/reference/tsbuild/configFileErrors/no-change-run/reports-syntax-errors-in-config-file.js create mode 100644 tests/baselines/reference/tsbuild/watchMode/configFileErrors/reports-syntax-errors-in-config-file.js diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index a7cadbf3bcb..f2da5cee744 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -828,7 +828,7 @@ namespace ts { if (state.options.verbose) reportStatus(state, Diagnostics.Building_project_0, project); if (config.fileNames.length === 0) { - reportAndStoreErrors(state, projectPath, config.errors); + reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config)); // Nothing to build - must be a solution file, basically buildResult = BuildResultFlags.None; step = Step.QueueReferencingProjects; @@ -846,7 +846,7 @@ namespace ts { config.options, compilerHost, getOldProgram(state, projectPath, config), - config.errors, + getConfigFileParsingDiagnostics(config), config.projectReferences ); step++; @@ -1118,7 +1118,7 @@ namespace ts { function needsBuild({ options }: SolutionBuilderState, status: UpToDateStatus, config: ParsedCommandLine) { if (status.type !== UpToDateStatusType.OutOfDateWithPrepend || options.force) return true; return config.fileNames.length === 0 || - !!config.errors.length || + !!getConfigFileParsingDiagnostics(config).length || !isIncrementalCompilation(config.options); } @@ -1172,7 +1172,7 @@ namespace ts { verboseReportProjectStatus(state, project, status); if (!options.force) { if (status.type === UpToDateStatusType.UpToDate) { - reportAndStoreErrors(state, projectPath, config.errors); + reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config)); projectPendingBuild.delete(projectPath); // Up to date, skip if (options.dry) { @@ -1183,7 +1183,7 @@ namespace ts { } if (status.type === UpToDateStatusType.UpToDateWithUpstreamTypes) { - reportAndStoreErrors(state, projectPath, config.errors); + reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config)); return createUpdateOutputFileStampsProject( state, project, @@ -1195,7 +1195,7 @@ namespace ts { } if (status.type === UpToDateStatusType.UpstreamBlocked) { - reportAndStoreErrors(state, projectPath, config.errors); + reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config)); projectPendingBuild.delete(projectPath); if (options.verbose) { reportStatus( @@ -1211,7 +1211,7 @@ namespace ts { } if (status.type === UpToDateStatusType.ContainerOnly) { - reportAndStoreErrors(state, projectPath, config.errors); + reportAndStoreErrors(state, projectPath, getConfigFileParsingDiagnostics(config)); projectPendingBuild.delete(projectPath); // Do nothing continue; diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 7b05f9cd270..73ccca0bac2 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -107,6 +107,7 @@ "unittests/services/textChanges.ts", "unittests/services/transpile.ts", "unittests/tsbuild/amdModulesWithOut.ts", + "unittests/tsbuild/configFileErrors.ts", "unittests/tsbuild/containerOnlyReferenced.ts", "unittests/tsbuild/demo.ts", "unittests/tsbuild/emitDeclarationOnly.ts", @@ -116,7 +117,6 @@ "unittests/tsbuild/inferredTypeFromTransitiveModule.ts", "unittests/tsbuild/javascriptProjectEmit.ts", "unittests/tsbuild/lateBoundSymbol.ts", - "unittests/tsbuild/missingExtendedFile.ts", "unittests/tsbuild/moduleSpecifiers.ts", "unittests/tsbuild/noEmitOnError.ts", "unittests/tsbuild/outFile.ts", diff --git a/src/testRunner/unittests/tsbuild/configFileErrors.ts b/src/testRunner/unittests/tsbuild/configFileErrors.ts new file mode 100644 index 00000000000..5d222958870 --- /dev/null +++ b/src/testRunner/unittests/tsbuild/configFileErrors.ts @@ -0,0 +1,57 @@ +namespace ts { + describe("unittests:: tsbuild:: configFileErrors:: when tsconfig extends the missing file", () => { + verifyTsc({ + scenario: "configFileErrors", + subScenario: "when tsconfig extends the missing file", + fs: () => loadProjectFromDisk("tests/projects/missingExtendedConfig"), + commandLineArgs: ["--b", "/src/tsconfig.json"], + }); + }); + + describe("unittests:: tsbuild:: configFileErrors:: reports syntax errors in config file", () => { + verifyTscIncrementalEdits({ + scenario: "configFileErrors", + subScenario: "reports syntax errors in config file", + fs: () => loadProjectFromFiles({ + "/src/a.ts": "export function foo() { }", + "/src/b.ts": "export function bar() { }", + "/src/tsconfig.json": Utils.dedent` +{ + "compilerOptions": { + "composite": true, + }, + "files": [ + "a.ts" + "b.ts" + ] +}` + }), + commandLineArgs: ["--b", "/src/tsconfig.json"], + incrementalScenarios: [ + { + buildKind: BuildKind.IncrementalDtsUnchanged, + modifyFs: fs => replaceText(fs, "/src/tsconfig.json", ",", `, + "declaration": true,`), + subScenario: "reports syntax errors after change to config file" + }, + { + buildKind: BuildKind.IncrementalDtsUnchanged, + modifyFs: fs => appendText(fs, "/src/a.ts", "export function fooBar() { }"), + subScenario: "reports syntax errors after change to ts file" + }, + noChangeRun, + { + buildKind: BuildKind.IncrementalDtsChange, + modifyFs: fs => fs.writeFileSync( + "/src/tsconfig.json", + JSON.stringify({ + compilerOptions: { composite: true, declaration: true }, + files: ["a.ts", "b.ts"] + }) + ), + subScenario: "builds after fixing config file errors" + }, + ] + }); + }); +} diff --git a/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts b/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts index d1bcb321e52..8a208a698fa 100644 --- a/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts +++ b/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts @@ -1,18 +1,9 @@ namespace ts { describe("unittests:: tsbuild:: when containerOnly project is referenced", () => { - let projFs: vfs.FileSystem; - before(() => { - projFs = loadProjectFromDisk("tests/projects/containerOnlyReferenced"); - }); - - after(() => { - projFs = undefined!; // Release the contents - }); - verifyTscIncrementalEdits({ scenario: "containerOnlyReferenced", subScenario: "verify that subsequent builds after initial build doesnt build anything", - fs: () => projFs, + fs: () => loadProjectFromDisk("tests/projects/containerOnlyReferenced"), commandLineArgs: ["--b", "/src", "--verbose"], incrementalScenarios: [noChangeRun] }); diff --git a/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts b/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts index 433f5443098..2f8284849cf 100644 --- a/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts +++ b/src/testRunner/unittests/tsbuild/javascriptProjectEmit.ts @@ -212,7 +212,7 @@ namespace ts { { "extends": "../tsconfig.base.json", "compilerOptions": { - "outDir": null + "outDir": null, "composite": true }, "include": ["index.ts", "obj.json"] diff --git a/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts b/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts index f2cbfca320e..15ac34c222c 100644 --- a/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts +++ b/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts @@ -1,16 +1,8 @@ namespace ts { describe("unittests:: tsbuild:: lateBoundSymbol:: interface is merged and contains late bound member", () => { - let projFs: vfs.FileSystem; - before(() => { - projFs = loadProjectFromDisk("tests/projects/lateBoundSymbol"); - }); - after(() => { - projFs = undefined!; // Release the contents - }); - verifyTscIncrementalEdits({ subScenario: "interface is merged and contains late bound member", - fs: () => projFs, + fs: () => loadProjectFromDisk("tests/projects/lateBoundSymbol"), scenario: "lateBoundSymbol", commandLineArgs: ["--b", "/src/tsconfig.json", "--verbose"], incrementalScenarios: [{ diff --git a/src/testRunner/unittests/tsbuild/missingExtendedFile.ts b/src/testRunner/unittests/tsbuild/missingExtendedFile.ts deleted file mode 100644 index 398b38fdbea..00000000000 --- a/src/testRunner/unittests/tsbuild/missingExtendedFile.ts +++ /dev/null @@ -1,17 +0,0 @@ -namespace ts { - describe("unittests:: tsbuild:: when tsconfig extends the missing file", () => { - let projFs: vfs.FileSystem; - before(() => { - projFs = loadProjectFromDisk("tests/projects/missingExtendedConfig"); - }); - after(() => { - projFs = undefined!; - }); - verifyTsc({ - scenario: "missingExtendedConfig", - subScenario: "when tsconfig extends the missing file", - fs: () => projFs, - commandLineArgs: ["--b", "/src/tsconfig.json"], - }); - }); -} diff --git a/src/testRunner/unittests/tsbuild/noEmitOnError.ts b/src/testRunner/unittests/tsbuild/noEmitOnError.ts index 54241d936b8..41afbca2dd9 100644 --- a/src/testRunner/unittests/tsbuild/noEmitOnError.ts +++ b/src/testRunner/unittests/tsbuild/noEmitOnError.ts @@ -1,16 +1,9 @@ namespace ts { describe("unittests:: tsbuild - with noEmitOnError", () => { - let projFs: vfs.FileSystem; - before(() => { - projFs = loadProjectFromDisk("tests/projects/noEmitOnError"); - }); - after(() => { - projFs = undefined!; - }); verifyTsc({ scenario: "noEmitOnError", subScenario: "has empty files diagnostic when files is empty and no references are provided", - fs: () => projFs, + fs: () => loadProjectFromDisk("tests/projects/noEmitOnError"), commandLineArgs: ["--b", "/src/tsconfig.json"], }); }); diff --git a/src/testRunner/unittests/tsbuild/outFile.ts b/src/testRunner/unittests/tsbuild/outFile.ts index c352481979c..a4594409042 100644 --- a/src/testRunner/unittests/tsbuild/outFile.ts +++ b/src/testRunner/unittests/tsbuild/outFile.ts @@ -453,7 +453,7 @@ namespace ts { function stripInternalOfThird(fs: vfs.FileSystem) { replaceText(fs, sources[project.third][source.config], `"declaration": true,`, `"declaration": true, -"stripInternal": true`); + "stripInternal": true,`); } function stripInternalScenario(fs: vfs.FileSystem, removeCommentsDisabled?: boolean, jsDocStyle?: boolean) { diff --git a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts index 3d1d8c3549d..0a5144da7c2 100644 --- a/src/testRunner/unittests/tsbuild/resolveJsonModule.ts +++ b/src/testRunner/unittests/tsbuild/resolveJsonModule.ts @@ -71,19 +71,10 @@ export default hello.hello`); }); describe("unittests:: tsbuild:: with resolveJsonModule option on project importJsonFromProjectReference", () => { - let projFs: vfs.FileSystem; - before(() => { - projFs = loadProjectFromDisk("tests/projects/importJsonFromProjectReference"); - }); - - after(() => { - projFs = undefined!; // Release the contents - }); - verifyTscIncrementalEdits({ scenario: "resolveJsonModule", subScenario: "importing json module from project reference", - fs: () => projFs, + fs: () => loadProjectFromDisk("tests/projects/importJsonFromProjectReference"), commandLineArgs: ["--b", "src/tsconfig.json", "--verbose"], incrementalScenarios: [noChangeRun] }); diff --git a/src/testRunner/unittests/tsbuild/watchMode.ts b/src/testRunner/unittests/tsbuild/watchMode.ts index 0452cce8ac4..0bdc20cff97 100644 --- a/src/testRunner/unittests/tsbuild/watchMode.ts +++ b/src/testRunner/unittests/tsbuild/watchMode.ts @@ -1266,8 +1266,7 @@ const a = { ), changes: [ sys => { - const content = sys.readFile(`${projectsLocation}/reexport/src/pure/session.ts`)!; - sys.writeFile(`${projectsLocation}/reexport/src/pure/session.ts`, content.replace("// ", "")); + replaceFileText(sys, `${projectsLocation}/reexport/src/pure/session.ts`, "// ", ""); sys.checkTimeoutQueueLengthAndRun(1); // build src/pure sys.checkTimeoutQueueLengthAndRun(1); // build src/main sys.checkTimeoutQueueLengthAndRun(1); // build src @@ -1275,8 +1274,7 @@ const a = { return "Introduce error"; }, sys => { - const content = sys.readFile(`${projectsLocation}/reexport/src/pure/session.ts`)!; - sys.writeFile(`${projectsLocation}/reexport/src/pure/session.ts`, content.replace("bar: ", "// bar: ")); + replaceFileText(sys, `${projectsLocation}/reexport/src/pure/session.ts`, "bar: ", "// bar: "); sys.checkTimeoutQueueLengthAndRun(1); // build src/pure sys.checkTimeoutQueueLengthAndRun(1); // build src/main sys.checkTimeoutQueueLengthAndRun(1); // build src @@ -1286,4 +1284,63 @@ const a = { ] }); }); + + describe("unittests:: tsbuild:: watchMode:: configFileErrors:: reports syntax errors in config file", () => { + verifyTscWatch({ + scenario: "configFileErrors", + subScenario: "reports syntax errors in config file", + sys: () => createWatchedSystem( + [ + { path: `${projectRoot}/a.ts`, content: "export function foo() { }" }, + { path: `${projectRoot}/b.ts`, content: "export function bar() { }" }, + { + path: `${projectRoot}/tsconfig.json`, + content: Utils.dedent` +{ + "compilerOptions": { + "composite": true, + }, + "files": [ + "a.ts" + "b.ts" + ] +}` + }, + libFile + ], + { currentDirectory: projectRoot } + ), + commandLineArgs: ["--b", "-w"], + changes: [ + sys => { + replaceFileText(sys, `${projectRoot}/tsconfig.json`, ",", `, + "declaration": true,`); + sys.checkTimeoutQueueLengthAndRun(1); // build the project + sys.checkTimeoutQueueLength(0); + return "reports syntax errors after change to config file"; + }, + sys => { + replaceFileText(sys, `${projectRoot}/a.ts`, "foo", "fooBar"); + sys.checkTimeoutQueueLengthAndRun(1); // build the project + sys.checkTimeoutQueueLength(0); + return "reports syntax errors after change to ts file"; + }, + sys => { + replaceFileText(sys, `${projectRoot}/tsconfig.json`, "", ""); + sys.checkTimeoutQueueLengthAndRun(1); // build the project + sys.checkTimeoutQueueLength(0); + return "reports error when there is no change to tsconfig file"; + }, + sys => { + sys.writeFile(`${projectRoot}/tsconfig.json`, JSON.stringify({ + compilerOptions: { composite: true, declaration: true }, + files: ["a.ts", "b.ts"] + })); + sys.checkTimeoutQueueLengthAndRun(1); // build the project + sys.checkTimeoutQueueLength(0); + return "builds after fixing config file errors"; + } + ] + }); + }); } diff --git a/src/testRunner/unittests/tscWatch/helpers.ts b/src/testRunner/unittests/tscWatch/helpers.ts index 9057ba2b4e7..5809b5ee2e5 100644 --- a/src/testRunner/unittests/tscWatch/helpers.ts +++ b/src/testRunner/unittests/tscWatch/helpers.ts @@ -417,4 +417,9 @@ namespace ts.tscWatch { }); }); } + + export function replaceFileText(sys: WatchedSystem, file: string, searchValue: string | RegExp, replaceValue: string) { + const content = Debug.assertDefined(sys.readFile(file)); + sys.writeFile(file, content.replace(searchValue, replaceValue)); + } } diff --git a/src/testRunner/unittests/tscWatch/programUpdates.ts b/src/testRunner/unittests/tscWatch/programUpdates.ts index a8396936bd3..b500092269b 100644 --- a/src/testRunner/unittests/tscWatch/programUpdates.ts +++ b/src/testRunner/unittests/tscWatch/programUpdates.ts @@ -1086,8 +1086,7 @@ export function two() { }); function changeParameterTypeOfBFile(sys: WatchedSystem, parameterName: string, toType: string) { - const oldContent = sys.readFile(`${projectRoot}/b.ts`)!; - sys.writeFile(`${projectRoot}/b.ts`, oldContent.replace(new RegExp(`${parameterName}\: [a-z]*`), `${parameterName}: ${toType}`)); + replaceFileText(sys, `${projectRoot}/b.ts`, new RegExp(`${parameterName}\: [a-z]*`), `${parameterName}: ${toType}`); sys.runQueuedTimeoutCallbacks(); return `Changed ${parameterName} type to ${toType}`; } diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-emitHelpers-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-emitHelpers-in-all-projects.js index a2965cde2de..bafbf3b3eb9 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-emitHelpers-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-emitHelpers-in-all-projects.js @@ -1046,7 +1046,7 @@ declare function appfile4Spread(...b: number[]): void; "declarationMap": true, "outFile": "module.js" }, - "exclude": ["module.d.ts"] + "exclude": ["module.d.ts"], "references": [ { "path": "../lib", "prepend": true } ] diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-prologues-in-all-projects.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-prologues-in-all-projects.js index ce52dcebd47..ac1ede399eb 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-prologues-in-all-projects.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/multiple-prologues-in-all-projects.js @@ -679,7 +679,7 @@ declare const myVar = 30; "declarationMap": true, "outFile": "module.js" }, - "exclude": ["module.d.ts"] + "exclude": ["module.d.ts"], "references": [ { "path": "../lib", "prepend": true } ] diff --git a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js index 04bdb8e9b46..f3692954f93 100644 --- a/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js +++ b/tests/baselines/reference/tsbuild/amdModulesWithOut/initial-build/stripInternal.js @@ -2092,7 +2092,7 @@ declare const myVar = 30; "declarationMap": true, "outFile": "module.js" }, - "exclude": ["module.d.ts"] + "exclude": ["module.d.ts"], "references": [ { "path": "../lib", "prepend": true } ] diff --git a/tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-changes/builds-after-fixing-config-file-errors.js b/tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-changes/builds-after-fixing-config-file-errors.js new file mode 100644 index 00000000000..86979ff9c5f --- /dev/null +++ b/tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-changes/builds-after-fixing-config-file-errors.js @@ -0,0 +1,63 @@ +//// [/lib/incremental-declaration-changesOutput.txt] +/lib/tsc --b /src/tsconfig.json +exitCode:: ExitStatus.Success + + +//// [/src/a.d.ts] +export declare function foo(): void; + + +//// [/src/a.js] +"use strict"; +exports.__esModule = true; +function foo() { } +exports.foo = foo; + + +//// [/src/b.d.ts] +export declare function bar(): void; + + +//// [/src/b.js] +"use strict"; +exports.__esModule = true; +function bar() { } +exports.bar = bar; + + +//// [/src/tsconfig.json] +{"compilerOptions":{"composite":true,"declaration":true},"files":["a.ts","b.ts"]} + +//// [/src/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "../lib/lib.d.ts": { + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };" + }, + "./a.ts": { + "version": "4646078106-export function foo() { }", + "signature": "-6972466928-export declare function foo(): void;\r\n" + }, + "./b.ts": { + "version": "1045484683-export function bar() { }", + "signature": "-1357953631-export declare function bar(): void;\r\n" + } + }, + "options": { + "composite": true, + "declaration": true, + "configFilePath": "./tsconfig.json" + }, + "referencedMap": {}, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "../lib/lib.d.ts", + "./a.ts", + "./b.ts" + ] + }, + "version": "FakeTSVersion" +} + diff --git a/tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-doesnt-change/reports-syntax-errors-after-change-to-config-file.js b/tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-doesnt-change/reports-syntax-errors-after-change-to-config-file.js new file mode 100644 index 00000000000..c5f31f8e8b6 --- /dev/null +++ b/tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-doesnt-change/reports-syntax-errors-after-change-to-config-file.js @@ -0,0 +1,18 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/tsconfig.json +src/tsconfig.json(8,9): error TS1005: ',' expected. +exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped + + +//// [/src/tsconfig.json] +{ + "compilerOptions": { + "composite": true, + "declaration": true, + }, + "files": [ + "a.ts" + "b.ts" + ] +} + diff --git a/tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-doesnt-change/reports-syntax-errors-after-change-to-ts-file.js b/tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-doesnt-change/reports-syntax-errors-after-change-to-ts-file.js new file mode 100644 index 00000000000..6bafb2968e9 --- /dev/null +++ b/tests/baselines/reference/tsbuild/configFileErrors/incremental-declaration-doesnt-change/reports-syntax-errors-after-change-to-ts-file.js @@ -0,0 +1,9 @@ +//// [/lib/incremental-declaration-doesnt-changeOutput.txt] +/lib/tsc --b /src/tsconfig.json +src/tsconfig.json(7,9): error TS1005: ',' expected. +exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped + + +//// [/src/a.ts] +export function foo() { }export function fooBar() { } + diff --git a/tests/baselines/reference/tsbuild/configFileErrors/initial-build/reports-syntax-errors-in-config-file.js b/tests/baselines/reference/tsbuild/configFileErrors/initial-build/reports-syntax-errors-in-config-file.js new file mode 100644 index 00000000000..b7e1d4a6632 --- /dev/null +++ b/tests/baselines/reference/tsbuild/configFileErrors/initial-build/reports-syntax-errors-in-config-file.js @@ -0,0 +1,6 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc --b /src/tsconfig.json +src/tsconfig.json(7,9): error TS1005: ',' expected. +exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped + + diff --git a/tests/baselines/reference/tsbuild/missingExtendedConfig/initial-build/when-tsconfig-extends-the-missing-file.js b/tests/baselines/reference/tsbuild/configFileErrors/initial-build/when-tsconfig-extends-the-missing-file.js similarity index 100% rename from tests/baselines/reference/tsbuild/missingExtendedConfig/initial-build/when-tsconfig-extends-the-missing-file.js rename to tests/baselines/reference/tsbuild/configFileErrors/initial-build/when-tsconfig-extends-the-missing-file.js diff --git a/tests/baselines/reference/tsbuild/configFileErrors/no-change-run/reports-syntax-errors-in-config-file.js b/tests/baselines/reference/tsbuild/configFileErrors/no-change-run/reports-syntax-errors-in-config-file.js new file mode 100644 index 00000000000..2778f443b00 --- /dev/null +++ b/tests/baselines/reference/tsbuild/configFileErrors/no-change-run/reports-syntax-errors-in-config-file.js @@ -0,0 +1,6 @@ +//// [/lib/no-change-runOutput.txt] +/lib/tsc --b /src/tsconfig.json +src/tsconfig.json(7,9): error TS1005: ',' expected. +exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped + + diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-baseline-when-internal-is-inside-another-internal.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-baseline-when-internal-is-inside-another-internal.js index 5c650827310..ac134802dac 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-baseline-when-internal-is-inside-another-internal.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-baseline-when-internal-is-inside-another-internal.js @@ -2236,7 +2236,7 @@ declare var c: C; "sourceMap": true, "declarationMap": true, "declaration": true, -"stripInternal": true + "stripInternal": true, "outFile": "./thirdjs/output/third-output.js", "skipDefaultLibCheck": true }, diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js index b6a9dac9f4b..00ff72bcf89 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment-when-one-two-three-are-prepended-in-order.js @@ -5583,7 +5583,7 @@ declare var c: C; "sourceMap": true, "declarationMap": true, "declaration": true, -"stripInternal": true + "stripInternal": true, "outFile": "./thirdjs/output/third-output.js", "skipDefaultLibCheck": true }, diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js index 34b42935b4f..a14e55563e2 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-comment.js @@ -5274,7 +5274,7 @@ declare var c: C; "sourceMap": true, "declarationMap": true, "declaration": true, -"stripInternal": true + "stripInternal": true, "outFile": "./thirdjs/output/third-output.js", "skipDefaultLibCheck": true }, diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index 1d167197b09..8161491dfa1 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -5947,7 +5947,7 @@ declare var c: C; "sourceMap": true, "declarationMap": true, "declaration": true, -"stripInternal": true + "stripInternal": true, "outFile": "./thirdjs/output/third-output.js", "skipDefaultLibCheck": true }, diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js index f55627f1e1f..e204773e731 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-jsdoc-style-with-comments-emit-enabled.js @@ -5650,7 +5650,7 @@ declare var c: C; "sourceMap": true, "declarationMap": true, "declaration": true, -"stripInternal": true + "stripInternal": true, "outFile": "./thirdjs/output/third-output.js", "skipDefaultLibCheck": true }, diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-few-members-of-enum-are-internal.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-few-members-of-enum-are-internal.js index ac4b4506e9c..404f87e44a4 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-few-members-of-enum-are-internal.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-few-members-of-enum-are-internal.js @@ -2726,7 +2726,7 @@ declare var c: C; "sourceMap": true, "declarationMap": true, "declaration": true, -"stripInternal": true + "stripInternal": true, "outFile": "./thirdjs/output/third-output.js", "skipDefaultLibCheck": true }, diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js index 33043052625..73d35c2cde7 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-when-one-two-three-are-prepended-in-order.js @@ -5603,7 +5603,7 @@ declare var c: C; "sourceMap": true, "declarationMap": true, "declaration": true, -"stripInternal": true + "stripInternal": true, "outFile": "./thirdjs/output/third-output.js", "skipDefaultLibCheck": true }, diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js index fb179a1c7a3..4dea6e9474e 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled-when-one-two-three-are-prepended-in-order.js @@ -5805,7 +5805,7 @@ declare var c: C; "sourceMap": true, "declarationMap": true, "declaration": true, -"stripInternal": true + "stripInternal": true, "outFile": "./thirdjs/output/third-output.js", "skipDefaultLibCheck": true }, diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js index e6ce5a30667..37ffe232878 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal-with-comments-emit-enabled.js @@ -5514,7 +5514,7 @@ declare var c: C; "sourceMap": true, "declarationMap": true, "declaration": true, -"stripInternal": true + "stripInternal": true, "outFile": "./thirdjs/output/third-output.js", "skipDefaultLibCheck": true }, diff --git a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js index 064e40bdfc9..17dd04d9da0 100644 --- a/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js +++ b/tests/baselines/reference/tsbuild/outfile-concat/initial-build/stripInternal.js @@ -5294,7 +5294,7 @@ declare var c: C; "sourceMap": true, "declarationMap": true, "declaration": true, -"stripInternal": true + "stripInternal": true, "outFile": "./thirdjs/output/third-output.js", "skipDefaultLibCheck": true }, diff --git a/tests/baselines/reference/tsbuild/watchMode/configFileErrors/reports-syntax-errors-in-config-file.js b/tests/baselines/reference/tsbuild/watchMode/configFileErrors/reports-syntax-errors-in-config-file.js new file mode 100644 index 00000000000..2e28c1a91a5 --- /dev/null +++ b/tests/baselines/reference/tsbuild/watchMode/configFileErrors/reports-syntax-errors-in-config-file.js @@ -0,0 +1,289 @@ +/a/lib/tsc.js --b -w +//// [/user/username/projects/myproject/a.ts] +export function foo() { } + +//// [/user/username/projects/myproject/b.ts] +export function bar() { } + +//// [/user/username/projects/myproject/tsconfig.json] +{ + "compilerOptions": { + "composite": true, + }, + "files": [ + "a.ts" + "b.ts" + ] +} + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +Output:: +>> Screen clear +12:00:23 AM - Starting compilation in watch mode... + + +tsconfig.json(7,9): error TS1005: ',' expected. + + +12:00:24 AM - Found 1 error. Watching for file changes. + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"composite":true,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":250} +/user/username/projects/myproject/a.ts: + {"pollingInterval":250} +/user/username/projects/myproject/b.ts: + {"pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +Change:: reports syntax errors after change to config file + +//// [/user/username/projects/myproject/tsconfig.json] +{ + "compilerOptions": { + "composite": true, + "declaration": true, + }, + "files": [ + "a.ts" + "b.ts" + ] +} + + +Output:: +>> Screen clear +12:00:28 AM - File change detected. Starting incremental compilation... + + +tsconfig.json(8,9): error TS1005: ',' expected. + + +12:00:29 AM - Found 1 error. Watching for file changes. + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"composite":true,"declaration":true,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":250} +/user/username/projects/myproject/a.ts: + {"pollingInterval":250} +/user/username/projects/myproject/b.ts: + {"pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +Change:: reports syntax errors after change to ts file + +//// [/user/username/projects/myproject/a.ts] +export function fooBar() { } + + +Output:: +>> Screen clear +12:00:33 AM - File change detected. Starting incremental compilation... + + +tsconfig.json(8,9): error TS1005: ',' expected. + + +12:00:34 AM - Found 1 error. Watching for file changes. + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"composite":true,"declaration":true,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":250} +/user/username/projects/myproject/a.ts: + {"pollingInterval":250} +/user/username/projects/myproject/b.ts: + {"pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +Change:: reports error when there is no change to tsconfig file + +//// [/user/username/projects/myproject/tsconfig.json] file written with same contents + +Output:: +>> Screen clear +12:00:38 AM - File change detected. Starting incremental compilation... + + +tsconfig.json(8,9): error TS1005: ',' expected. + + +12:00:39 AM - Found 1 error. Watching for file changes. + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"composite":true,"declaration":true,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +No cached semantic diagnostics in the builder:: + +WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":250} +/user/username/projects/myproject/a.ts: + {"pollingInterval":250} +/user/username/projects/myproject/b.ts: + {"pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +Change:: builds after fixing config file errors + +//// [/user/username/projects/myproject/tsconfig.json] +{"compilerOptions":{"composite":true,"declaration":true},"files":["a.ts","b.ts"]} + +//// [/user/username/projects/myproject/a.js] +"use strict"; +exports.__esModule = true; +function fooBar() { } +exports.fooBar = fooBar; + + +//// [/user/username/projects/myproject/a.d.ts] +export declare function fooBar(): void; + + +//// [/user/username/projects/myproject/b.js] +"use strict"; +exports.__esModule = true; +function bar() { } +exports.bar = bar; + + +//// [/user/username/projects/myproject/b.d.ts] +export declare function bar(): void; + + +//// [/user/username/projects/myproject/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "../../../../a/lib/lib.d.ts": { + "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", + "signature": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }" + }, + "./a.ts": { + "version": "-3260843409-export function fooBar() { }", + "signature": "-6611919720-export declare function fooBar(): void;\n" + }, + "./b.ts": { + "version": "1045484683-export function bar() { }", + "signature": "-2904461644-export declare function bar(): void;\n" + } + }, + "options": { + "composite": true, + "declaration": true, + "watch": true, + "configFilePath": "./tsconfig.json" + }, + "referencedMap": {}, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "../../../../a/lib/lib.d.ts", + "./a.ts", + "./b.ts" + ] + }, + "version": "FakeTSVersion" +} + + +Output:: +>> Screen clear +12:00:43 AM - File change detected. Starting incremental compilation... + + + +12:00:54 AM - Found 0 errors. Watching for file changes. + + +Program root files: ["/user/username/projects/myproject/a.ts","/user/username/projects/myproject/b.ts"] +Program options: {"composite":true,"declaration":true,"watch":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} +Program files:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +/user/username/projects/myproject/a.ts +/user/username/projects/myproject/b.ts + +WatchedFiles:: +/user/username/projects/myproject/tsconfig.json: + {"pollingInterval":250} +/user/username/projects/myproject/a.ts: + {"pollingInterval":250} +/user/username/projects/myproject/b.ts: + {"pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined diff --git a/tests/projects/amdModulesWithOut/app/tsconfig.json b/tests/projects/amdModulesWithOut/app/tsconfig.json index aef2d9fefab..f73bf9c8be2 100644 --- a/tests/projects/amdModulesWithOut/app/tsconfig.json +++ b/tests/projects/amdModulesWithOut/app/tsconfig.json @@ -8,7 +8,7 @@ "declarationMap": true, "outFile": "module.js" }, - "exclude": ["module.d.ts"] + "exclude": ["module.d.ts"], "references": [ { "path": "../lib", "prepend": true } ]