Skip to content

Commit 490927a

Browse files
committed
Create ancestor project if load is pending or if project is composite
1 parent 5860fe7 commit 490927a

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/server/editorServices.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,7 +2490,10 @@ namespace ts.server {
24902490
* Traverse till project Root and create those configured projects
24912491
*/
24922492
private createAncestorConfiguredProjects(info: ScriptInfo, project: ConfiguredProject) {
2493-
if (!project.containsScriptInfo(info) || !project.getCompilerOptions().composite) return;
2493+
if (!project.containsScriptInfo(info) || !project.getCompilerOptions().composite) {
2494+
return;
2495+
}
2496+
24942497
const configPath = this.toPath(project.canonicalConfigFilePath);
24952498
const configInfo: OriginalFileInfo = {
24962499
fileName: project.getConfigFilePath(),
@@ -2503,11 +2506,14 @@ namespace ts.server {
25032506
const configFileName = this.getConfigFileNameForFile(configInfo);
25042507
if (!configFileName) return;
25052508

2506-
// TODO: may be we should create only first project and then once its loaded,
2507-
// do pending search if this is composite ?
25082509
const ancestor = this.findConfiguredProjectByProjectName(configFileName) ||
25092510
this.createConfiguredProjectWithDelayLoad(configFileName, `Project possibly referencing default composite project ${project.getProjectName()} of open file ${info.fileName}`);
2510-
ancestor.setPotentialProjectRefence(configPath);
2511+
if (ancestor.isInitialLoadPending()) {
2512+
ancestor.setPotentialProjectRefence(configPath);
2513+
}
2514+
else if (!project.getCompilerOptions().composite) {
2515+
return;
2516+
}
25112517

25122518
configInfo.fileName = configFileName;
25132519
configInfo.path = this.toPath(configFileName);

src/server/project.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,9 +1440,8 @@ namespace ts.server {
14401440

14411441
setPotentialProjectRefence(path: Path) {
14421442
// We know the composites if we have read the config file
1443-
if (this.isInitialLoadPending()) {
1444-
(this.potentialProjectReferences || (this.potentialProjectReferences = createMap())).set(path, true);
1445-
}
1443+
Debug.assert(this.isInitialLoadPending());
1444+
(this.potentialProjectReferences || (this.potentialProjectReferences = createMap())).set(path, true);
14461445
}
14471446

14481447
/*@internal*/

0 commit comments

Comments
 (0)