Add location info to empty lists diagnostics when tsconfig file exists

This commit is contained in:
christian 2018-09-06 20:40:02 -04:00
parent ea984d7b64
commit ec72f4751d
2 changed files with 10 additions and 5 deletions

View File

@ -1846,7 +1846,14 @@ namespace ts {
const hasReferences = hasProperty(raw, "references") && !isNullOrUndefined(raw.references);
const hasZeroOrNoReferences = !hasReferences || raw.references.length === 0;
if (filesSpecs.length === 0 && hasZeroOrNoReferences) {
errors.push(createCompilerDiagnostic(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json"));
if (sourceFile) {
const nodeValue = firstDefined(getTsConfigPropArray(sourceFile, "files"), property => property.initializer);
const error = createDiagnosticForNodeInSourceFile(sourceFile, nodeValue!, Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
errors.push(error);
}
else {
createCompilerDiagnosticOnlyIfJson(Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
}
}
}
else {

View File

@ -290,8 +290,7 @@ namespace ts {
"/apath/tsconfig.json",
"tests/cases/unittests",
["/apath/a.ts"],
Diagnostics.The_files_list_in_config_file_0_is_empty.code,
/*noLocation*/ true);
Diagnostics.The_files_list_in_config_file_0_is_empty.code);
});
it("generates errors for empty files list when no references are provided", () => {
@ -303,8 +302,7 @@ namespace ts {
"/apath/tsconfig.json",
"tests/cases/unittests",
["/apath/a.ts"],
Diagnostics.The_files_list_in_config_file_0_is_empty.code,
/*noLocation*/ true);
Diagnostics.The_files_list_in_config_file_0_is_empty.code);
});
it("does not generate errors for empty files list when one or more references are provided", () => {