File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff 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 [ ] ;
You can’t perform that action at this time.
0 commit comments