Skip to content

Commit 121a350

Browse files
committed
Instead of adding lib files, avoid creating diagnostics producing checker for container projects
1 parent 851f739 commit 121a350

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/compiler/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ namespace ts {
726726
// - The '--noLib' flag is used.
727727
// - A 'no-default-lib' reference comment is encountered in
728728
// processing the root files.
729-
if (!skipDefaultLib) {
729+
if (rootNames.length && !skipDefaultLib) {
730730
// If '--lib' is not specified, include default library file according to '--target'
731731
// otherwise, using options specified in '--lib' instead of '--target' default library file
732732
const defaultLibraryFileName = getDefaultLibraryFileName();
@@ -1841,7 +1841,7 @@ namespace ts {
18411841
}
18421842

18431843
function getGlobalDiagnostics(): SortedReadonlyArray<Diagnostic> {
1844-
return sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice());
1844+
return rootNames.length ? sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : emptyArray as any as SortedReadonlyArray<Diagnostic>;
18451845
}
18461846

18471847
function getConfigFileParsingDiagnostics(): ReadonlyArray<Diagnostic> {

src/testRunner/unittests/tscWatchMode.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,10 @@ namespace ts.tscWatch {
10741074
const host = createWatchedSystem([file1, configFile, libFile]);
10751075
const watch = createWatchOfConfigFile(configFile.path, host);
10761076

1077-
checkProgramActualFiles(watch(), [libFile.path]);
1077+
checkProgramActualFiles(watch(), emptyArray);
1078+
checkOutputErrorsInitial(host, [
1079+
"error TS18003: No inputs were found in config file '/a/b/tsconfig.json'. Specified 'include' paths were '[\"app/*\",\"test/**/*\",\"something\"]' and 'exclude' paths were '[]'.\n"
1080+
]);
10781081
});
10791082

10801083
it("non-existing directories listed in config file input array should be able to handle @types if input file list is empty", () => {
@@ -1100,7 +1103,10 @@ namespace ts.tscWatch {
11001103
const host = createWatchedSystem([f, config, t1, t2], { currentDirectory: getDirectoryPath(f.path) });
11011104
const watch = createWatchOfConfigFile(config.path, host);
11021105

1103-
checkProgramActualFiles(watch(), [t1.path, t2.path]);
1106+
checkProgramActualFiles(watch(), emptyArray);
1107+
checkOutputErrorsInitial(host, [
1108+
"tsconfig.json(1,24): error TS18002: The 'files' list in config file '/a/tsconfig.json' is empty.\n"
1109+
]);
11041110
});
11051111

11061112
it("should support files without extensions", () => {

src/testRunner/unittests/tsserverProjectSystem.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,7 +3061,7 @@ namespace ts.projectSystem {
30613061
const configProject = configuredProjectAt(projectService, 0);
30623062
checkProjectActualFiles(configProject, lazyConfiguredProjectsFromExternalProject ?
30633063
emptyArray : // Since no files opened from this project, its not loaded
3064-
[libFile.path, configFile.path]);
3064+
[configFile.path]);
30653065

30663066
host.reloadFS([libFile, site]);
30673067
host.checkTimeoutQueueLengthAndRun(1);
@@ -10521,7 +10521,7 @@ declare class TestLib {
1052110521
assert.deepEqual(semanticDiagnostics, []);
1052210522
});
1052310523
const containerProject = service.configuredProjects.get(containerConfig.path)!;
10524-
checkProjectActualFiles(containerProject, [containerConfig.path, libFile.path]);
10524+
checkProjectActualFiles(containerProject, [containerConfig.path]);
1052510525
const optionsDiagnostics = session.executeCommandSeq<protocol.CompilerOptionsDiagnosticsRequest>({
1052610526
command: protocol.CommandTypes.CompilerOptionsDiagnosticsFull,
1052710527
arguments: { projectFileName: containerProject.projectName }

0 commit comments

Comments
 (0)