Lookup files by resolved Path and not by fileName in sourcemapDecoder when querying program (#25908)

* Check if the file returned by the program actually refers to the same file as we intend

* Simplify
This commit is contained in:
Wesley Wigham
2018-07-24 15:44:22 -07:00
committed by GitHub
parent f6d3ac9b5d
commit 23eb591e01
3 changed files with 61 additions and 3 deletions
+2 -2
View File
@@ -98,10 +98,10 @@ namespace ts.sourcemaps {
function getSourceFileLike(fileName: string, location: string): SourceFileLike | undefined {
// Lookup file in program, if provided
const file = program && program.getSourceFile(fileName);
const path = toPath(fileName, location, host.getCanonicalFileName);
const file = program && program.getSourceFile(path);
if (!file) {
// Otherwise check the cache (which may hit disk)
const path = toPath(fileName, location, host.getCanonicalFileName);
return fallbackCache.get(path);
}
return file;