mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix premature closing of AutoImportProviderProject for unbuilt monorepos (#40620)
* Fix premature closing of AutoImportProviderProject for unbuilt monorepos * Update src/server/project.ts Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com> * Update API baseline * Don’t override hasRoots * Update API baselines * Really actually update baselines Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
co-authored by
Daniel Rosenwasser
parent
a1a9d6d2f8
commit
3b9eb1ebe9
@@ -1671,7 +1671,7 @@ namespace ts.server {
|
||||
}
|
||||
if (this.autoImportProviderHost) {
|
||||
updateProjectIfDirty(this.autoImportProviderHost);
|
||||
if (!this.autoImportProviderHost.hasRoots()) {
|
||||
if (this.autoImportProviderHost.isEmpty()) {
|
||||
this.autoImportProviderHost.close();
|
||||
this.autoImportProviderHost = undefined;
|
||||
return undefined;
|
||||
@@ -1935,6 +1935,11 @@ namespace ts.server {
|
||||
this.rootFileNames = initialRootNames;
|
||||
}
|
||||
|
||||
/*@internal*/
|
||||
isEmpty() {
|
||||
return !some(this.rootFileNames);
|
||||
}
|
||||
|
||||
isOrphan() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -283,6 +283,25 @@ namespace ts.projectSystem {
|
||||
// Project for A is created - ensure it doesn't have an autoImportProvider
|
||||
assert.isUndefined(projectService.configuredProjects.get("/packages/a/tsconfig.json")!.getLanguageService().getAutoImportProvider());
|
||||
});
|
||||
|
||||
it("Does not close when root files are redirects that don't actually exist", () => {
|
||||
const files = [
|
||||
// packages/a
|
||||
{ path: "/packages/a/package.json", content: `{ "dependencies": { "b": "*" } }` },
|
||||
{ path: "/packages/a/tsconfig.json", content: `{ "compilerOptions": { "composite": true }, "references": [{ "path": "./node_modules/b" }] }` },
|
||||
{ path: "/packages/a/index.ts", content: "" },
|
||||
|
||||
// packages/b
|
||||
{ path: "/packages/a/node_modules/b/package.json", content: `{ "types": "dist/index.d.ts" }` },
|
||||
{ path: "/packages/a/node_modules/b/tsconfig.json", content: `{ "compilerOptions": { "composite": true, "outDir": "dist" } }` },
|
||||
{ path: "/packages/a/node_modules/b/index.ts", content: `export class B {}` }
|
||||
];
|
||||
|
||||
const { projectService, session } = setup(files);
|
||||
openFilesForSession([files[2]], session);
|
||||
assert.isDefined(projectService.configuredProjects.get("/packages/a/tsconfig.json")!.getPackageJsonAutoImportProvider());
|
||||
assert.isDefined(projectService.configuredProjects.get("/packages/a/tsconfig.json")!.getPackageJsonAutoImportProvider());
|
||||
});
|
||||
});
|
||||
|
||||
function setup(files: File[]) {
|
||||
|
||||
Reference in New Issue
Block a user