Merge pull request #20664 from RyanCavanaugh/clearResolutionCache

Clear the module resolution cache when new @types appear
This commit is contained in:
Ryan Cavanaugh 2017-12-13 09:40:16 -08:00 committed by GitHub
commit 65e92c624b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -1009,7 +1009,7 @@ namespace ts.projectSystem {
installer.installAll(/*expectedCount*/ 1);
});
it("cached unresolved typings are not recomputed if program structure did not change", () => {
it("should recompute resolutions after typings are installed", () => {
const host = createServerHost([]);
const session = createSession(host);
const f = {
@ -1051,7 +1051,7 @@ namespace ts.projectSystem {
session.executeCommand(changeRequest);
host.checkTimeoutQueueLengthAndRun(2); // This enqueues the updategraph and refresh inferred projects
const version2 = proj.getCachedUnresolvedImportsPerFile_TestOnly().getVersion();
assert.equal(version1, version2, "set of unresolved imports should not change");
assert.notEqual(version1, version2, "set of unresolved imports should change");
});
});

View file

@ -547,9 +547,11 @@ namespace ts.server {
}
switch (response.kind) {
case ActionSet:
project.resolutionCache.clear();
this.typingsCache.updateTypingsForProject(response.projectName, response.compilerOptions, response.typeAcquisition, response.unresolvedImports, response.typings);
break;
case ActionInvalidate:
project.resolutionCache.clear();
this.typingsCache.deleteTypingsForProject(response.projectName);
break;
}