Skip to content

Commit 16477b6

Browse files
committed
Take into account undefined nodeValue when recording diagnostic
1 parent ec72f47 commit 16477b6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/compiler/commandLineParser.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,8 +1847,12 @@ namespace ts {
18471847
const hasZeroOrNoReferences = !hasReferences || raw.references.length === 0;
18481848
if (filesSpecs.length === 0 && hasZeroOrNoReferences) {
18491849
if (sourceFile) {
1850+
const fileName = configFileName || "tsconfig.json";
1851+
const diagnosticMessage = Diagnostics.The_files_list_in_config_file_0_is_empty;
18501852
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");
1853+
const error = nodeValue
1854+
? createDiagnosticForNodeInSourceFile(sourceFile, nodeValue, diagnosticMessage, fileName)
1855+
: createCompilerDiagnostic(diagnosticMessage, fileName);
18521856
errors.push(error);
18531857
}
18541858
else {

0 commit comments

Comments
 (0)