mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-25 05:29:07 -05:00
Fix the assert of reporting file infos still attached to the project for circular json reference
This commit is contained in:
@@ -1087,7 +1087,24 @@ namespace ts.server {
|
||||
|
||||
project.close();
|
||||
if (Debug.shouldAssert(AssertionLevel.Normal)) {
|
||||
this.filenameToScriptInfo.forEach(info => Debug.assert(!info.isAttached(project), "Found script Info still attached to project", () => `${project.projectName}: ScriptInfos still attached: ${JSON.stringify(mapDefined(arrayFrom(this.filenameToScriptInfo.values()), info => info.isAttached(project) ? info : undefined))}`));
|
||||
this.filenameToScriptInfo.forEach(info => Debug.assert(
|
||||
!info.isAttached(project),
|
||||
"Found script Info still attached to project",
|
||||
() => `${project.projectName}: ScriptInfos still attached: ${JSON.stringify(
|
||||
arrayFrom(
|
||||
mapDefinedIterator(
|
||||
this.filenameToScriptInfo.values(),
|
||||
info => info.isAttached(project) ?
|
||||
{
|
||||
fileName: info.fileName,
|
||||
projects: info.containingProjects.map(p => p.projectName),
|
||||
hasMixedContent: info.hasMixedContent
|
||||
} : undefined
|
||||
)
|
||||
),
|
||||
/*replacer*/ undefined,
|
||||
" "
|
||||
)}`));
|
||||
}
|
||||
// Remove the project from pending project updates
|
||||
this.pendingProjectUpdates.delete(project.getProjectName());
|
||||
|
||||
@@ -1467,5 +1467,22 @@ var x = 10;`
|
||||
openFilesForSession([{ file, projectRootPath }], session);
|
||||
}
|
||||
});
|
||||
|
||||
it("assert when removing project", () => {
|
||||
const host = createServerHost([commonFile1, commonFile2, libFile]);
|
||||
const service = createProjectService(host);
|
||||
service.openClientFile(commonFile1.path);
|
||||
const project = service.inferredProjects[0];
|
||||
checkProjectActualFiles(project, [commonFile1.path, libFile.path]);
|
||||
// Intentionally create scriptinfo and attach it to project
|
||||
const info = service.getOrCreateScriptInfoForNormalizedPath(commonFile2.path as server.NormalizedPath, /*openedByClient*/ false)!;
|
||||
info.attachToProject(project);
|
||||
try {
|
||||
service.applyChangesInOpenFiles(/*openFiles*/ undefined, /*changedFiles*/ undefined, [commonFile1.path]);
|
||||
}
|
||||
catch (e) {
|
||||
assert.isTrue(e.message.indexOf("Debug Failure. False expression: Found script Info still attached to project") === 0);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user