@@ -101,7 +101,9 @@ export function createCompiler(configs: ConfigSet): TsCompiler {
101101 ? configs . filterDiagnostics ( result . diagnostics )
102102 : [ ]
103103
104- if ( diagnosticList . length ) throw configs . createTsError ( diagnosticList )
104+ if ( diagnosticList . length ) {
105+ throw configs . createTsError ( diagnosticList )
106+ }
105107
106108 return [ result . outputText , result . sourceMapText as string ]
107109 }
@@ -174,16 +176,18 @@ export function createCompiler(configs: ConfigSet): TsCompiler {
174176
175177 const output = service . getEmitOutput ( fileName )
176178
177- // Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
178- const diagnostics = service
179- . getCompilerOptionsDiagnostics ( )
180- . concat ( service . getSyntacticDiagnostics ( fileName ) )
181- . concat ( service . getSemanticDiagnostics ( fileName ) )
179+ if ( configs . shouldReportDiagnostic ( fileName ) ) {
180+ // Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
181+ const diagnostics = service
182+ . getCompilerOptionsDiagnostics ( )
183+ . concat ( service . getSyntacticDiagnostics ( fileName ) )
184+ . concat ( service . getSemanticDiagnostics ( fileName ) )
182185
183- const diagnosticList = configs . filterDiagnostics ( diagnostics )
186+ const diagnosticList = configs . filterDiagnostics ( diagnostics )
184187
185- if ( diagnosticList . length ) {
186- throw configs . createTsError ( diagnosticList )
188+ if ( diagnosticList . length ) {
189+ throw configs . createTsError ( diagnosticList )
190+ }
187191 }
188192
189193 if ( output . emitSkipped ) {
0 commit comments