From 30da23fa7770cc8bac06f776522ddfa79df8b4a5 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Thu, 30 Nov 2017 10:22:41 -0800 Subject: [PATCH 1/4] Handle failure to properly resolve type reference directives --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 405fd11f138..c797200bff2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25000,10 +25000,11 @@ namespace ts { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = createMap(); resolvedTypeReferenceDirectives.forEach((resolvedDirective, key) => { - if (!resolvedDirective) { + if (!resolvedDirective || !resolvedDirective.resolvedFileName) { return; } const file = host.getSourceFile(resolvedDirective.resolvedFileName); + Debug.assert(!!file, `Resolved filename ${resolvedDirective.resolvedFileName} did not map to existing source file. Consider enabling --preserveSymlinks if appropriate`); // tslint:disable-line fileToDirective.set(file.path, key); }); } From 1fc6675a2973b2ad361ab3bf4c946bc48baeeb95 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Wed, 6 Dec 2017 14:40:59 -0800 Subject: [PATCH 2/4] Allow for undefined return from TypeCheckerHost.getSourceFile to correspond with implementation --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f6ca2f45d34..6ab0f5543ec 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2736,7 +2736,7 @@ namespace ts { getCompilerOptions(): CompilerOptions; getSourceFiles(): ReadonlyArray; - getSourceFile(fileName: string): SourceFile; + getSourceFile(fileName: string): SourceFile | undefined; getResolvedTypeReferenceDirectives(): ReadonlyMap; } From 46fa477c156f9771e8be4cb70eff3a1458cb7962 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 19 Jan 2018 16:22:09 -0800 Subject: [PATCH 3/4] Move assertion to realpath evaluation --- src/compiler/checker.ts | 1 - src/compiler/moduleNameResolver.ts | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c797200bff2..41e1ed99dc6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -25004,7 +25004,6 @@ namespace ts { return; } const file = host.getSourceFile(resolvedDirective.resolvedFileName); - Debug.assert(!!file, `Resolved filename ${resolvedDirective.resolvedFileName} did not map to existing source file. Consider enabling --preserveSymlinks if appropriate`); // tslint:disable-line fileToDirective.set(file.path, key); }); } diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index f72876bd5fc..e0acf43eadf 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -782,6 +782,7 @@ namespace ts { if (traceEnabled) { trace(host, Diagnostics.Resolving_real_path_for_0_result_1, path, real); } + Debug.assert(host.fileExists(real), `${path} linked to non-existing file ${real}`); // tslint:disable-line return real; } From 4a877897792ec3ec58ab06991d314af03dc37181 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Fri, 19 Jan 2018 16:40:52 -0800 Subject: [PATCH 4/4] Fix typo in message --- src/compiler/moduleNameResolver.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index e0acf43eadf..4f893302693 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -782,7 +782,7 @@ namespace ts { if (traceEnabled) { trace(host, Diagnostics.Resolving_real_path_for_0_result_1, path, real); } - Debug.assert(host.fileExists(real), `${path} linked to non-existing file ${real}`); // tslint:disable-line + Debug.assert(host.fileExists(real), `${path} linked to nonexistent file ${real}`); // tslint:disable-line return real; }