Skip to content

Commit 7bf382e

Browse files
authored
Allow empty files lists in tsconfigs with an extends member (#27383)
1 parent 5f2741b commit 7bf382e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/compiler/commandLineParser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,8 @@ namespace ts {
18951895
filesSpecs = <ReadonlyArray<string>>raw.files;
18961896
const hasReferences = hasProperty(raw, "references") && !isNullOrUndefined(raw.references);
18971897
const hasZeroOrNoReferences = !hasReferences || raw.references.length === 0;
1898-
if (filesSpecs.length === 0 && hasZeroOrNoReferences) {
1898+
const hasExtends = hasProperty(raw, "extends");
1899+
if (filesSpecs.length === 0 && hasZeroOrNoReferences && !hasExtends) {
18991900
if (sourceFile) {
19001901
const fileName = configFileName || "tsconfig.json";
19011902
const diagnosticMessage = Diagnostics.The_files_list_in_config_file_0_is_empty;

src/testRunner/unittests/configurationExtension.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ namespace ts {
9696
include: null,
9797
files: ["../main.ts"]
9898
}),
99+
"dev/configs/fifth.json": JSON.stringify({
100+
extends: "./fourth",
101+
include: ["../tests/utils.ts"],
102+
files: []
103+
}),
99104
"dev/extends.json": JSON.stringify({ extends: 42 }),
100105
"dev/extends2.json": JSON.stringify({ extends: "configs/base" }),
101106
"dev/main.ts": "",
@@ -245,6 +250,15 @@ namespace ts {
245250
combinePaths(basePath, "main.ts")
246251
]);
247252

253+
testSuccess("can overwrite top-level files using extended []", "configs/fifth.json", {
254+
allowJs: true,
255+
noImplicitAny: true,
256+
strictNullChecks: true,
257+
module: ModuleKind.System
258+
}, [
259+
combinePaths(basePath, "tests/utils.ts")
260+
]);
261+
248262
it("adds extendedSourceFiles only once", () => {
249263
const sourceFile = readJsonConfigFile("configs/fourth.json", (path) => host.readFile(path));
250264
const dir = combinePaths(basePath, "configs");

0 commit comments

Comments
 (0)