Skip to content

Commit 7e9e29c

Browse files
committed
Store + use the resolved path of sourceFiles in proj. ref. scenarios
1 parent 8bc1932 commit 7e9e29c

4 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/compiler/program.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ namespace ts {
987987

988988
for (const oldSourceFile of oldSourceFiles) {
989989
let newSourceFile = host.getSourceFileByPath
990-
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target!, /*onError*/ undefined, shouldCreateNewSourceFile)
990+
? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath || oldSourceFile.path, options.target!, /*onError*/ undefined, shouldCreateNewSourceFile)
991991
: host.getSourceFile(oldSourceFile.fileName, options.target!, /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
992992

993993
if (!newSourceFile) {
@@ -1991,6 +1991,7 @@ namespace ts {
19911991
if (file) {
19921992
sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
19931993
file.path = path;
1994+
file.resolvedPath = toPath(fileName);
19941995

19951996
if (host.useCaseSensitiveFileNames()) {
19961997
const pathLowerCase = path.toLowerCase();

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,6 +2551,7 @@ namespace ts {
25512551
fileName: string;
25522552
/* @internal */ path: Path;
25532553
text: string;
2554+
/* @internal */ resolvedPath: Path;
25542555

25552556
/**
25562557
* If two source files are for the same version of the same package, one will redirect to the other.

src/server/project.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ namespace ts.server {
629629
return this.rootFiles;
630630
}
631631
return map(this.program.getSourceFiles(), sourceFile => {
632-
const scriptInfo = this.projectService.getScriptInfoForPath(sourceFile.path);
633-
Debug.assert(!!scriptInfo, "getScriptInfo", () => `scriptInfo for a file '${sourceFile.fileName}' Path: '${sourceFile.path}' is missing.`);
632+
const scriptInfo = this.projectService.getScriptInfoForPath(sourceFile.resolvedPath || sourceFile.path);
633+
Debug.assert(!!scriptInfo, "getScriptInfo", () => `scriptInfo for a file '${sourceFile.fileName}' Path: '${sourceFile.path}' / '${sourceFile.resolvedPath}' is missing.`);
634634
return scriptInfo!;
635635
});
636636
}

src/services/services.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ namespace ts {
540540
public _declarationBrand: any;
541541
public fileName: string;
542542
public path: Path;
543+
public resolvedPath: Path;
543544
public text: string;
544545
public scriptSnapshot: IScriptSnapshot;
545546
public lineMap: ReadonlyArray<number>;

0 commit comments

Comments
 (0)