Skip to content

Commit 43bd2d8

Browse files
committed
Changes from CR feedback
1 parent 1b16c0b commit 43bd2d8

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/compiler/program.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,11 @@ namespace ts {
727727
function getSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
728728
// For JavaScript files, we report semantic errors for using TypeScript-only
729729
// constructs from within a JavaScript file as syntactic errors.
730-
if (isSourceFileJavaScript(sourceFile) && !sourceFile.parseJavaScriptDiagnostics) {
731-
sourceFile.parseJavaScriptDiagnostics = getJavaScriptSemanticDiagnosticsForFile(sourceFile);
732-
sourceFile.parseDiagnostics = sourceFile.parseDiagnostics.concat(sourceFile.parseJavaScriptDiagnostics);
730+
if (isSourceFileJavaScript(sourceFile)) {
731+
if (!sourceFile.additionalSyntacticDiagnostics) {
732+
sourceFile.additionalSyntacticDiagnostics = getJavaScriptSyntacticDiagnosticsForFile(sourceFile);
733+
}
734+
return concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
733735
}
734736
return sourceFile.parseDiagnostics;
735737
}
@@ -774,7 +776,7 @@ namespace ts {
774776
});
775777
}
776778

777-
function getJavaScriptSemanticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
779+
function getJavaScriptSyntacticDiagnosticsForFile(sourceFile: SourceFile): Diagnostic[] {
778780
return runWithCancellationToken(() => {
779781
const diagnostics: Diagnostic[] = [];
780782
walk(sourceFile);

src/compiler/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,8 +2024,8 @@ namespace ts {
20242024
// as well as code diagnostics).
20252025
/* @internal */ parseDiagnostics: Diagnostic[];
20262026

2027-
// Stores file level JavaScript diagnostics reported by the program
2028-
/* @internal */ parseJavaScriptDiagnostics?: Diagnostic[];
2027+
// Stores additional file level diagnostics reported by the program
2028+
/* @internal */ additionalSyntacticDiagnostics?: Diagnostic[];
20292029

20302030
// File level diagnostics reported by the binder.
20312031
/* @internal */ bindDiagnostics: Diagnostic[];

0 commit comments

Comments
 (0)