mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Component commits: c3ac7fa2e7 Handle the fact that noResolveResolution resolution is reused Fixes #39795 Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
This commit is contained in:
parent
3a6dde0b6b
commit
7cf61845c9
@ -406,7 +406,7 @@ namespace ts {
|
||||
perDirectoryResolution.set(name, resolution);
|
||||
}
|
||||
resolutionsInFile.set(name, resolution);
|
||||
watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
|
||||
watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName, noResolveResolution);
|
||||
if (existingResolution) {
|
||||
stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
|
||||
}
|
||||
@ -561,6 +561,7 @@ namespace ts {
|
||||
resolution: T,
|
||||
filePath: Path,
|
||||
getResolutionWithResolvedFileName: GetResolutionWithResolvedFileName<T, R>,
|
||||
noResolveResolution: T
|
||||
) {
|
||||
if (resolution.refCount) {
|
||||
resolution.refCount++;
|
||||
@ -568,7 +569,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
resolution.refCount = 1;
|
||||
Debug.assert(resolution.files === undefined);
|
||||
Debug.assert(resolution.files === undefined || (resolution === noResolveResolution && length(noResolveResolution.files) === 0));
|
||||
if (isExternalModuleNameRelative(name)) {
|
||||
watchFailedLookupLocationOfResolution(resolution);
|
||||
}
|
||||
|
||||
@ -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]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user