Skip to content

Commit e422dae

Browse files
committed
Create ancestor project if load is pending or if project is composite
1 parent 8854037 commit e422dae

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
@@ -2509,7 +2509,10 @@ namespace ts.server {
25092509
* Traverse till project Root and create those configured projects
25102510
*/
25112511
private createAncestorConfiguredProjects(info: ScriptInfo, project: ConfiguredProject) {
2512-
if (!project.containsScriptInfo(info) || !project.getCompilerOptions().composite) return;
2512+
if (!project.containsScriptInfo(info) || !project.getCompilerOptions().composite) {
2513+
return;
2514+
}
2515+
25132516
const configPath = this.toPath(project.canonicalConfigFilePath);
25142517
const configInfo: OriginalFileInfo = {
25152518
fileName: project.getConfigFilePath(),
@@ -2522,11 +2525,14 @@ namespace ts.server {
25222525
const configFileName = this.getConfigFileNameForFile(configInfo);
25232526
if (!configFileName) return;
25242527

2525-
// TODO: may be we should create only first project and then once its loaded,
2526-
// do pending search if this is composite ?
25272528
const ancestor = this.findConfiguredProjectByProjectName(configFileName) ||
25282529
this.createConfiguredProjectWithDelayLoad(configFileName, `Project possibly referencing default composite project ${project.getProjectName()} of open file ${info.fileName}`);
2529-
ancestor.setPotentialProjectRefence(configPath);
2530+
if (ancestor.isInitialLoadPending()) {
2531+
ancestor.setPotentialProjectRefence(configPath);
2532+
}
2533+
else if (!project.getCompilerOptions().composite) {
2534+
return;
2535+
}
25302536

25312537
configInfo.fileName = configFileName;
25322538
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)