From 121a350c5da04ddbc5bf2243a990af17fdd03ced Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 31 Oct 2018 19:00:55 -0700 Subject: [PATCH] Instead of adding lib files, avoid creating diagnostics producing checker for container projects --- src/compiler/program.ts | 4 ++-- src/testRunner/unittests/tscWatchMode.ts | 10 ++++++++-- src/testRunner/unittests/tsserverProjectSystem.ts | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ca8731a533..15c09a1a79 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -726,7 +726,7 @@ namespace ts { // - The '--noLib' flag is used. // - A 'no-default-lib' reference comment is encountered in // processing the root files. - if (!skipDefaultLib) { + if (rootNames.length && !skipDefaultLib) { // If '--lib' is not specified, include default library file according to '--target' // otherwise, using options specified in '--lib' instead of '--target' default library file const defaultLibraryFileName = getDefaultLibraryFileName(); @@ -1841,7 +1841,7 @@ namespace ts { } function getGlobalDiagnostics(): SortedReadonlyArray { - return sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); + return rootNames.length ? sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : emptyArray as any as SortedReadonlyArray; } function getConfigFileParsingDiagnostics(): ReadonlyArray { diff --git a/src/testRunner/unittests/tscWatchMode.ts b/src/testRunner/unittests/tscWatchMode.ts index ca00e08fdd..3523db7544 100644 --- a/src/testRunner/unittests/tscWatchMode.ts +++ b/src/testRunner/unittests/tscWatchMode.ts @@ -1074,7 +1074,10 @@ namespace ts.tscWatch { const host = createWatchedSystem([file1, configFile, libFile]); const watch = createWatchOfConfigFile(configFile.path, host); - checkProgramActualFiles(watch(), [libFile.path]); + checkProgramActualFiles(watch(), emptyArray); + checkOutputErrorsInitial(host, [ + "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" + ]); }); 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 { const host = createWatchedSystem([f, config, t1, t2], { currentDirectory: getDirectoryPath(f.path) }); const watch = createWatchOfConfigFile(config.path, host); - checkProgramActualFiles(watch(), [t1.path, t2.path]); + checkProgramActualFiles(watch(), emptyArray); + checkOutputErrorsInitial(host, [ + "tsconfig.json(1,24): error TS18002: The 'files' list in config file '/a/tsconfig.json' is empty.\n" + ]); }); it("should support files without extensions", () => { diff --git a/src/testRunner/unittests/tsserverProjectSystem.ts b/src/testRunner/unittests/tsserverProjectSystem.ts index c4dc4b9216..3b7e3d61a7 100644 --- a/src/testRunner/unittests/tsserverProjectSystem.ts +++ b/src/testRunner/unittests/tsserverProjectSystem.ts @@ -3061,7 +3061,7 @@ namespace ts.projectSystem { const configProject = configuredProjectAt(projectService, 0); checkProjectActualFiles(configProject, lazyConfiguredProjectsFromExternalProject ? emptyArray : // Since no files opened from this project, its not loaded - [libFile.path, configFile.path]); + [configFile.path]); host.reloadFS([libFile, site]); host.checkTimeoutQueueLengthAndRun(1); @@ -10521,7 +10521,7 @@ declare class TestLib { assert.deepEqual(semanticDiagnostics, []); }); const containerProject = service.configuredProjects.get(containerConfig.path)!; - checkProjectActualFiles(containerProject, [containerConfig.path, libFile.path]); + checkProjectActualFiles(containerProject, [containerConfig.path]); const optionsDiagnostics = session.executeCommandSeq({ command: protocol.CommandTypes.CompilerOptionsDiagnosticsFull, arguments: { projectFileName: containerProject.projectName }