Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/compiler/resolutionCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ namespace ts {
}
else {
resolution.refCount = 1;
Debug.assert(resolution.files === undefined);
Debug.assert(length(resolution.files) === 0); // This resolution shouldnt be referenced by any file yet
if (isExternalModuleNameRelative(name)) {
watchFailedLookupLocationOfResolution(resolution);
}
Expand Down
18 changes: 18 additions & 0 deletions src/testRunner/unittests/tsserver/approximateSemanticOnlyServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,23 @@ function fooB() { }`
assert.isFalse(project.dirty);
checkProjectActualFiles(project, [libFile.path, file1.path, file2.path, file3.path, something.path]);
});

it("should not crash when external module name resolution is reused", () => {
const { session, file1, file2, file3 } = setup();
const service = session.getProjectService();
openFilesForSession([file1], session);
checkNumberOfProjects(service, { inferredProjects: 1 });
const project = service.inferredProjects[0];
checkProjectActualFiles(project, [libFile.path, file1.path, file2.path]);

// Close the file that contains non relative external module name and open some file that doesnt have non relative external module import
closeFilesForSession([file1], session);
openFilesForSession([file3], session);
checkProjectActualFiles(project, [libFile.path, file3.path]);

// Open file with non relative external module name
openFilesForSession([file2], session);
checkProjectActualFiles(project, [libFile.path, file2.path, file3.path]);
});
});
}