@@ -10,6 +10,7 @@ import { ConverterComponent, ConverterNodeComponent, ConverterTypeComponent, Typ
1010import { CompilerHost } from './utils/compiler-host' ;
1111import { Component , Option , ChildableComponent , ComponentClass } from '../utils/component' ;
1212import { normalizePath } from '../utils/fs' ;
13+ import { createMinimatch } from '../utils/paths' ;
1314
1415/**
1516 * Result structure of the [[Converter.convert]] method.
@@ -384,26 +385,33 @@ export class Converter extends ChildableComponent<Application, ConverterComponen
384385 private compile ( context : Context ) : ReadonlyArray < ts . Diagnostic > {
385386 const program = context . program ;
386387
387- program . getSourceFiles ( ) . forEach ( ( sourceFile ) => {
388+ const exclude = createMinimatch ( this . application . exclude || [ ] ) ;
389+ const isExcluded = ( file : ts . SourceFile ) => exclude . some ( mm => mm . match ( file . fileName ) ) ;
390+
391+ const includedSourceFiles = program . getSourceFiles ( )
392+ . filter ( file => ! isExcluded ( file ) ) ;
393+ const isRelevantError = ( { file } : ts . Diagnostic ) => ! file || includedSourceFiles . includes ( file ) ;
394+
395+ includedSourceFiles . forEach ( ( sourceFile ) => {
388396 this . convertNode ( context , sourceFile ) ;
389397 } ) ;
390398
391- let diagnostics = program . getOptionsDiagnostics ( ) ;
399+ let diagnostics = program . getOptionsDiagnostics ( ) . filter ( isRelevantError ) ;
392400 if ( diagnostics . length ) {
393401 return diagnostics ;
394402 }
395403
396- diagnostics = program . getSyntacticDiagnostics ( ) ;
404+ diagnostics = program . getSyntacticDiagnostics ( ) . filter ( isRelevantError ) ;
397405 if ( diagnostics . length ) {
398406 return diagnostics ;
399407 }
400408
401- diagnostics = program . getGlobalDiagnostics ( ) ;
409+ diagnostics = program . getGlobalDiagnostics ( ) . filter ( isRelevantError ) ;
402410 if ( diagnostics . length ) {
403411 return diagnostics ;
404412 }
405413
406- diagnostics = program . getSemanticDiagnostics ( ) ;
414+ diagnostics = program . getSemanticDiagnostics ( ) . filter ( isRelevantError ) ;
407415 if ( diagnostics . length ) {
408416 return diagnostics ;
409417 }
0 commit comments