Skip to content

Commit ea60e99

Browse files
committed
Get configFiles as part of file names
1 parent ec2f967 commit ea60e99

File tree

9 files changed

+67
-48
lines changed

9 files changed

+67
-48
lines changed

src/compiler/commandLineParser.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ namespace ts {
15261526
if (ownConfig.extendedConfigPath) {
15271527
// copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios.
15281528
resolutionStack = resolutionStack.concat([resolvedPath]);
1529-
const extendedConfig = getExtendedConfig(ownConfig.extendedConfigPath, host, basePath, getCanonicalFileName,
1529+
const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, getCanonicalFileName,
15301530
resolutionStack, errors);
15311531
if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
15321532
const baseRaw = extendedConfig.raw;
@@ -1674,6 +1674,7 @@ namespace ts {
16741674
}
16751675

16761676
function getExtendedConfig(
1677+
sourceFile: JsonSourceFile,
16771678
extendedConfigPath: Path,
16781679
host: ts.ParseConfigHost,
16791680
basePath: string,
@@ -1682,6 +1683,9 @@ namespace ts {
16821683
errors: Diagnostic[],
16831684
): ParsedTsconfig | undefined {
16841685
const extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path));
1686+
if (sourceFile) {
1687+
(sourceFile.extendedSourceFiles || (sourceFile.extendedSourceFiles = [])).push(extendedResult.fileName);
1688+
}
16851689
if (extendedResult.parseDiagnostics.length) {
16861690
errors.push(...extendedResult.parseDiagnostics);
16871691
return undefined;
@@ -1690,6 +1694,9 @@ namespace ts {
16901694
const extendedDirname = getDirectoryPath(extendedConfigPath);
16911695
const extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname,
16921696
getBaseFileName(extendedConfigPath), resolutionStack, errors);
1697+
if (sourceFile) {
1698+
sourceFile.extendedSourceFiles.push(...extendedResult.extendedSourceFiles);
1699+
}
16931700

16941701
if (isSuccessfulParsedTsconfig(extendedConfig)) {
16951702
// Update the paths to reflect base path

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,6 +2338,7 @@ namespace ts {
23382338

23392339
export interface JsonSourceFile extends SourceFile {
23402340
jsonObject?: ObjectLiteralExpression;
2341+
extendedSourceFiles?: string[];
23412342
}
23422343

23432344
export interface ScriptReferenceHost {

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ namespace ts.projectSystem {
731731
checkNumberOfConfiguredProjects(projectService, 1);
732732

733733
const project = projectService.configuredProjects[0];
734-
checkProjectActualFiles(project, [file1.path, libFile.path, file2.path]);
734+
checkProjectActualFiles(project, [file1.path, libFile.path, file2.path, configFile.path]);
735735
checkProjectRootFiles(project, [file1.path, file2.path]);
736736
// watching all files except one that was open
737737
checkWatchedFiles(host, [configFile.path, file2.path, libFile.path]);
@@ -988,7 +988,7 @@ namespace ts.projectSystem {
988988

989989
checkNumberOfConfiguredProjects(projectService, 1);
990990
const project = projectService.configuredProjects[0];
991-
checkProjectActualFiles(project, [file1.path, nodeModuleFile.path]);
991+
checkProjectActualFiles(project, [file1.path, nodeModuleFile.path, configFile.path]);
992992
checkNumberOfInferredProjects(projectService, 1);
993993

994994
configFile.content = `{
@@ -999,7 +999,7 @@ namespace ts.projectSystem {
999999
}`;
10001000
host.reloadFS(files);
10011001
host.triggerFileWatcherCallback(configFile.path);
1002-
checkProjectActualFiles(project, [file1.path, classicModuleFile.path]);
1002+
checkProjectActualFiles(project, [file1.path, classicModuleFile.path, configFile.path]);
10031003
checkNumberOfInferredProjects(projectService, 1);
10041004
});
10051005

@@ -1562,7 +1562,7 @@ namespace ts.projectSystem {
15621562
host.reloadFS([file1, file2, file3, configFile]);
15631563
host.triggerDirectoryWatcherCallback(getDirectoryPath(configFile.path), configFile.path);
15641564
checkNumberOfProjects(projectService, { configuredProjects: 1 });
1565-
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path, file3.path]);
1565+
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path, file3.path, configFile.path]);
15661566
});
15671567

15681568
it("correctly migrate files between projects", () => {
@@ -1620,7 +1620,7 @@ namespace ts.projectSystem {
16201620

16211621
projectService.openClientFile(file1.path);
16221622
checkNumberOfProjects(projectService, { configuredProjects: 1 });
1623-
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]);
1623+
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, configFile.path]);
16241624

16251625
host.reloadFS([file1, file2, configFile]);
16261626

@@ -1651,7 +1651,7 @@ namespace ts.projectSystem {
16511651

16521652
projectService.openClientFile(file1.path);
16531653
checkNumberOfProjects(projectService, { configuredProjects: 1 });
1654-
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]);
1654+
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, configFile.path]);
16551655

16561656
const modifiedConfigFile = {
16571657
path: configFile.path,
@@ -1684,7 +1684,7 @@ namespace ts.projectSystem {
16841684

16851685
projectService.openClientFile(file1.path);
16861686
checkNumberOfProjects(projectService, { configuredProjects: 1 });
1687-
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path]);
1687+
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path, configFile.path]);
16881688

16891689
const modifiedConfigFile = {
16901690
path: configFile.path,
@@ -1765,11 +1765,11 @@ namespace ts.projectSystem {
17651765

17661766
projectService.openClientFile(file1.path);
17671767
checkNumberOfProjects(projectService, { configuredProjects: 1 });
1768-
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path]);
1768+
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path, config.path]);
17691769

17701770
projectService.openClientFile(file2.path);
17711771
checkNumberOfProjects(projectService, { configuredProjects: 1 });
1772-
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path]);
1772+
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path, config.path]);
17731773

17741774
host.reloadFS([file1, file2]);
17751775
host.triggerFileWatcherCallback(config.path, /*removed*/ true);
@@ -1804,13 +1804,13 @@ namespace ts.projectSystem {
18041804
});
18051805
projectService.openClientFile(f1.path);
18061806
projectService.checkNumberOfProjects({ configuredProjects: 1 });
1807-
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path]);
1807+
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, config.path]);
18081808

18091809
projectService.closeClientFile(f1.path);
18101810

18111811
projectService.openClientFile(f2.path);
18121812
projectService.checkNumberOfProjects({ configuredProjects: 1, inferredProjects: 1 });
1813-
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path]);
1813+
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, config.path]);
18141814
checkProjectActualFiles(projectService.inferredProjects[0], [f2.path]);
18151815
});
18161816

@@ -1834,7 +1834,7 @@ namespace ts.projectSystem {
18341834

18351835
// HTML file will not be included in any projects yet
18361836
checkNumberOfProjects(projectService, { configuredProjects: 1 });
1837-
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]);
1837+
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, config.path]);
18381838

18391839
// Specify .html extension as mixed content
18401840
const extraFileExtensions = [{ extension: ".html", scriptKind: ScriptKind.JS, isMixedContent: true }];
@@ -1843,7 +1843,7 @@ namespace ts.projectSystem {
18431843

18441844
// HTML file still not included in the project as it is closed
18451845
checkNumberOfProjects(projectService, { configuredProjects: 1 });
1846-
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path]);
1846+
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, config.path]);
18471847

18481848
// Open HTML file
18491849
projectService.applyChangesInOpenFiles(
@@ -1853,7 +1853,7 @@ namespace ts.projectSystem {
18531853

18541854
// Now HTML file is included in the project
18551855
checkNumberOfProjects(projectService, { configuredProjects: 1 });
1856-
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path]);
1856+
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path, config.path]);
18571857

18581858
// Check identifiers defined in HTML content are available in .ts file
18591859
const project = projectService.configuredProjects[0];
@@ -1868,7 +1868,7 @@ namespace ts.projectSystem {
18681868

18691869
// HTML file is still included in project
18701870
checkNumberOfProjects(projectService, { configuredProjects: 1 });
1871-
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path]);
1871+
checkProjectActualFiles(projectService.configuredProjects[0], [file1.path, file2.path, config.path]);
18721872

18731873
// Check identifiers defined in HTML content are not available in .ts file
18741874
completions = project.getLanguageService().getCompletionsAtPosition(file1.path, 5);
@@ -2483,7 +2483,7 @@ namespace ts.projectSystem {
24832483
options: {}
24842484
});
24852485
projectService.checkNumberOfProjects({ configuredProjects: 1 });
2486-
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path]);
2486+
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, tsconfig.path]);
24872487

24882488
// rename tsconfig.json back to lib.ts
24892489
host.reloadFS([f1, f2]);
@@ -2541,8 +2541,8 @@ namespace ts.projectSystem {
25412541
options: {}
25422542
});
25432543
projectService.checkNumberOfProjects({ configuredProjects: 2 });
2544-
checkProjectActualFiles(projectService.configuredProjects[0], [cLib.path]);
2545-
checkProjectActualFiles(projectService.configuredProjects[1], [dLib.path]);
2544+
checkProjectActualFiles(projectService.configuredProjects[0], [cLib.path, cTsconfig.path]);
2545+
checkProjectActualFiles(projectService.configuredProjects[1], [dLib.path, dTsconfig.path]);
25462546

25472547
// remove one config file
25482548
projectService.openExternalProject({
@@ -2552,7 +2552,7 @@ namespace ts.projectSystem {
25522552
});
25532553

25542554
projectService.checkNumberOfProjects({ configuredProjects: 1 });
2555-
checkProjectActualFiles(projectService.configuredProjects[0], [dLib.path]);
2555+
checkProjectActualFiles(projectService.configuredProjects[0], [dLib.path, dTsconfig.path]);
25562556

25572557
// remove second config file
25582558
projectService.openExternalProject({
@@ -2572,8 +2572,8 @@ namespace ts.projectSystem {
25722572
options: {}
25732573
});
25742574
projectService.checkNumberOfProjects({ configuredProjects: 2 });
2575-
checkProjectActualFiles(projectService.configuredProjects[0], [cLib.path]);
2576-
checkProjectActualFiles(projectService.configuredProjects[1], [dLib.path]);
2575+
checkProjectActualFiles(projectService.configuredProjects[0], [cLib.path, cTsconfig.path]);
2576+
checkProjectActualFiles(projectService.configuredProjects[1], [dLib.path, dTsconfig.path]);
25772577

25782578
// close all projects - no projects should be opened
25792579
projectService.closeExternalProject(projectName);
@@ -2629,13 +2629,13 @@ namespace ts.projectSystem {
26292629
projectService.openClientFile(app.path);
26302630

26312631
projectService.checkNumberOfProjects({ configuredProjects: 1 });
2632-
checkProjectActualFiles(projectService.configuredProjects[0], [libES5.path, app.path]);
2632+
checkProjectActualFiles(projectService.configuredProjects[0], [libES5.path, app.path, config1.path]);
26332633

26342634
host.reloadFS([libES5, libES2015Promise, app, config2]);
26352635
host.triggerFileWatcherCallback(config1.path);
26362636

26372637
projectService.checkNumberOfProjects({ configuredProjects: 1 });
2638-
checkProjectActualFiles(projectService.configuredProjects[0], [libES5.path, libES2015Promise.path, app.path]);
2638+
checkProjectActualFiles(projectService.configuredProjects[0], [libES5.path, libES2015Promise.path, app.path, config2.path]);
26392639
});
26402640

26412641
it("should handle non-existing directories in config file", () => {
@@ -2690,7 +2690,7 @@ namespace ts.projectSystem {
26902690

26912691
projectService.openClientFile(f1.path);
26922692
projectService.checkNumberOfProjects({ configuredProjects: 1 });
2693-
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, barTypings.path]);
2693+
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, barTypings.path, config.path]);
26942694
});
26952695
});
26962696

@@ -2761,7 +2761,7 @@ namespace ts.projectSystem {
27612761

27622762
projectService.openClientFile(f1.path);
27632763
projectService.checkNumberOfProjects({ configuredProjects: 1 });
2764-
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, t1.path]);
2764+
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, t1.path, tsconfig.path]);
27652765

27662766
// delete t1
27672767
host.reloadFS([f1, tsconfig]);
@@ -2770,7 +2770,7 @@ namespace ts.projectSystem {
27702770
host.runQueuedTimeoutCallbacks();
27712771

27722772
projectService.checkNumberOfProjects({ configuredProjects: 1 });
2773-
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path]);
2773+
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, tsconfig.path]);
27742774

27752775
// create t2
27762776
host.reloadFS([f1, tsconfig, t2]);
@@ -2779,7 +2779,7 @@ namespace ts.projectSystem {
27792779
host.runQueuedTimeoutCallbacks();
27802780

27812781
projectService.checkNumberOfProjects({ configuredProjects: 1 });
2782-
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, t2.path]);
2782+
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, t2.path, tsconfig.path]);
27832783
});
27842784
});
27852785

@@ -2964,7 +2964,7 @@ namespace ts.projectSystem {
29642964
const projectService = createProjectService(host);
29652965
projectService.openClientFile(f1.path);
29662966
projectService.checkNumberOfProjects({ configuredProjects: 1 });
2967-
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, node.path]);
2967+
checkProjectActualFiles(projectService.configuredProjects[0], [f1.path, node.path, config.path]);
29682968
});
29692969
});
29702970

@@ -4040,4 +4040,4 @@ namespace ts.projectSystem {
40404040
}
40414041
});
40424042
});
4043-
}
4043+
}

src/harness/unittests/typingsInstaller.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace ts.projectSystem {
8080
const service = createProjectService(host, { typingsInstaller: installer });
8181
service.openClientFile(f1.path);
8282
service.checkNumberOfProjects({ configuredProjects: 1 });
83-
checkProjectActualFiles(service.configuredProjects[0], [f1.path, f2.path]);
83+
checkProjectActualFiles(service.configuredProjects[0], [f1.path, f2.path, config.path]);
8484
installer.installAll(0);
8585
});
8686
});
@@ -133,12 +133,12 @@ namespace ts.projectSystem {
133133

134134
checkNumberOfProjects(projectService, { configuredProjects: 1 });
135135
const p = projectService.configuredProjects[0];
136-
checkProjectActualFiles(p, [file1.path]);
136+
checkProjectActualFiles(p, [file1.path, tsconfig.path]);
137137

138138
installer.installAll(/*expectedCount*/ 1);
139139

140140
checkNumberOfProjects(projectService, { configuredProjects: 1 });
141-
checkProjectActualFiles(p, [file1.path, jquery.path]);
141+
checkProjectActualFiles(p, [file1.path, jquery.path, tsconfig.path]);
142142
});
143143

144144
it("inferred project (typings installed)", () => {
@@ -684,12 +684,12 @@ namespace ts.projectSystem {
684684

685685
checkNumberOfProjects(projectService, { configuredProjects: 1 });
686686
const p = projectService.configuredProjects[0];
687-
checkProjectActualFiles(p, [app.path]);
687+
checkProjectActualFiles(p, [app.path, jsconfig.path]);
688688

689689
installer.installAll(/*expectedCount*/ 1);
690690

691691
checkNumberOfProjects(projectService, { configuredProjects: 1 });
692-
checkProjectActualFiles(p, [app.path, jqueryDTS.path]);
692+
checkProjectActualFiles(p, [app.path, jqueryDTS.path, jsconfig.path]);
693693
});
694694

695695
it("configured projects discover from bower_components", () => {
@@ -730,13 +730,13 @@ namespace ts.projectSystem {
730730

731731
checkNumberOfProjects(projectService, { configuredProjects: 1 });
732732
const p = projectService.configuredProjects[0];
733-
checkProjectActualFiles(p, [app.path]);
733+
checkProjectActualFiles(p, [app.path, jsconfig.path]);
734734
checkWatchedFiles(host, [jsconfig.path, "/bower_components", "/node_modules"]);
735735

736736
installer.installAll(/*expectedCount*/ 1);
737737

738738
checkNumberOfProjects(projectService, { configuredProjects: 1 });
739-
checkProjectActualFiles(p, [app.path, jqueryDTS.path]);
739+
checkProjectActualFiles(p, [app.path, jqueryDTS.path, jsconfig.path]);
740740
});
741741

742742
it("configured projects discover from bower.json", () => {
@@ -777,12 +777,12 @@ namespace ts.projectSystem {
777777

778778
checkNumberOfProjects(projectService, { configuredProjects: 1 });
779779
const p = projectService.configuredProjects[0];
780-
checkProjectActualFiles(p, [app.path]);
780+
checkProjectActualFiles(p, [app.path, jsconfig.path]);
781781

782782
installer.installAll(/*expectedCount*/ 1);
783783

784784
checkNumberOfProjects(projectService, { configuredProjects: 1 });
785-
checkProjectActualFiles(p, [app.path, jqueryDTS.path]);
785+
checkProjectActualFiles(p, [app.path, jqueryDTS.path, jsconfig.path]);
786786
});
787787

788788
it("Malformed package.json should be watched", () => {
@@ -1185,4 +1185,4 @@ namespace ts.projectSystem {
11851185
checkProjectActualFiles(projectService.inferredProjects[0], [f1.path]);
11861186
});
11871187
});
1188-
}
1188+
}

src/server/project.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ namespace ts.server {
362362
return this.getLanguageService().getEmitOutput(info.fileName, emitOnlyDtsFiles);
363363
}
364364

365-
getFileNames(excludeFilesFromExternalLibraries?: boolean) {
365+
getFileNames(excludeFilesFromExternalLibraries?: boolean, excludeConfigFiles?: boolean) {
366366
if (!this.program) {
367367
return [];
368368
}
@@ -385,6 +385,17 @@ namespace ts.server {
385385
}
386386
result.push(asNormalizedPath(f.fileName));
387387
}
388+
if (!excludeConfigFiles) {
389+
const configFile = this.program.getCompilerOptions().configFile;
390+
if (configFile) {
391+
result.push(asNormalizedPath(configFile.fileName));
392+
if (configFile.extendedSourceFiles) {
393+
for (const f of configFile.extendedSourceFiles) {
394+
result.push(asNormalizedPath(f));
395+
}
396+
}
397+
}
398+
}
388399
return result;
389400
}
390401

0 commit comments

Comments
 (0)