Fix crash in reporting unresolved project reference as part of compilerOptions verification (#39095)

* Fix crash in reporting unresolved project reference as part of compilerOptions verification
Fixes #38143

* Fix typo
This commit is contained in:
Sheetal Nandi
2020-06-17 11:20:02 -07:00
committed by GitHub
parent 7611579421
commit 4105d32b7e
4 changed files with 69 additions and 1 deletions
+1 -1
View File
@@ -1530,7 +1530,7 @@ namespace ts {
function getPrependNodes() {
return createPrependNodes(
projectReferences,
(_ref, index) => resolvedProjectReferences![index]!.commandLine,
(_ref, index) => resolvedProjectReferences![index]?.commandLine,
fileName => {
const path = toPath(fileName);
const sourceFile = getSourceFileByPath(path);
+1
View File
@@ -130,6 +130,7 @@
"unittests/tsc/declarationEmit.ts",
"unittests/tsc/incremental.ts",
"unittests/tsc/listFilesOnly.ts",
"unittests/tsc/projectReferences.ts",
"unittests/tsc/runWithoutArgs.ts",
"unittests/tscWatch/consoleClearing.ts",
"unittests/tscWatch/emit.ts",
@@ -0,0 +1,21 @@
namespace ts {
describe("unittests:: tsc:: projectReferences::", () => {
verifyTsc({
scenario: "projectReferences",
subScenario: "when project contains invalid project reference",
fs: () => loadProjectFromFiles({
"/src/project/src/main.ts": "export const x = 10;",
"/src/project/tsconfig.json": JSON.stringify({
compilerOptions: {
module: "amd",
outFile: "theApp.js"
},
references: [
{ path: "../Util/Dates" }
]
}),
}),
commandLineArgs: ["--p", "src/project"],
});
});
}
@@ -0,0 +1,46 @@
Input::
//// [/lib/lib.d.ts]
/// <reference no-default-lib="true"/>
interface Boolean {}
interface Function {}
interface CallableFunction {}
interface NewableFunction {}
interface IArguments {}
interface Number { toExponential: any; }
interface Object {}
interface RegExp {}
interface String { charAt: any; }
interface Array<T> { length: number; [n: number]: T; }
interface ReadonlyArray<T> {}
declare const console: { log(msg: any): void; };
//// [/src/project/src/main.ts]
export const x = 10;
//// [/src/project/tsconfig.json]
{"compilerOptions":{"module":"amd","outFile":"theApp.js"},"references":[{"path":"../Util/Dates"}]}
Output::
/lib/tsc --p src/project
src/project/tsconfig.json:1:73 - error TS6053: File '/src/Util/Dates' not found.
1 {"compilerOptions":{"module":"amd","outFile":"theApp.js"},"references":[{"path":"../Util/Dates"}]}
   ~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error.
exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated
//// [/src/project/theApp.js]
define("main", ["require", "exports"], function (require, exports) {
"use strict";
exports.__esModule = true;
exports.x = void 0;
exports.x = 10;
});