From 8a87d519565544b7082510af7547b84919d1b88b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 15 Dec 2014 17:32:11 -0800 Subject: [PATCH] Do not use the file name in errors unless it exists --- src/compiler/parser.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index ea5b35cbce1..e145a4ec447 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5362,8 +5362,13 @@ module ts { // We haven't looked for this file, do so now and cache result var file = filesByName[canonicalName] = host.getSourceFile(filename, options.target, hostErrorMessage => { - errors.push(createFileDiagnostic(refFile, refStart, refLength, - Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage)); + if (refFile) { + errors.push(createFileDiagnostic(refFile, refStart, refLength, + Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage)); + } + else { + errors.push(createCompilerDiagnostic(Diagnostics.Cannot_read_file_0_Colon_1, filename, hostErrorMessage)); + } }); if (file) { seenNoDefaultLib = seenNoDefaultLib || file.hasNoDefaultLib;