Skip to content

Commit ec72f47

Browse files
committed
Add location info to empty lists diagnostics when tsconfig file exists
1 parent ea984d7 commit ec72f47

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/compiler/commandLineParser.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1846,7 +1846,14 @@ namespace ts {
18461846
const hasReferences = hasProperty(raw, "references") && !isNullOrUndefined(raw.references);
18471847
const hasZeroOrNoReferences = !hasReferences || raw.references.length === 0;
18481848
if (filesSpecs.length === 0 && hasZeroOrNoReferences) {
1849-
errors.push(createCompilerDiagnostic(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json"));
1849+
if (sourceFile) {
1850+
const nodeValue = firstDefined(getTsConfigPropArray(sourceFile, "files"), property => property.initializer);
1851+
const error = createDiagnosticForNodeInSourceFile(sourceFile, nodeValue!, Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
1852+
errors.push(error);
1853+
}
1854+
else {
1855+
createCompilerDiagnosticOnlyIfJson(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
1856+
}
18501857
}
18511858
}
18521859
else {

src/testRunner/unittests/tsconfigParsing.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,7 @@ namespace ts {
290290
"/apath/tsconfig.json",
291291
"tests/cases/unittests",
292292
["/apath/a.ts"],
293-
Diagnostics.The_files_list_in_config_file_0_is_empty.code,
294-
/*noLocation*/ true);
293+
Diagnostics.The_files_list_in_config_file_0_is_empty.code);
295294
});
296295

297296
it("generates errors for empty files list when no references are provided", () => {
@@ -303,8 +302,7 @@ namespace ts {
303302
"/apath/tsconfig.json",
304303
"tests/cases/unittests",
305304
["/apath/a.ts"],
306-
Diagnostics.The_files_list_in_config_file_0_is_empty.code,
307-
/*noLocation*/ true);
305+
Diagnostics.The_files_list_in_config_file_0_is_empty.code);
308306
});
309307

310308
it("does not generate errors for empty files list when one or more references are provided", () => {

0 commit comments

Comments
 (0)