@@ -1030,7 +1030,13 @@ namespace ts {
10301030 }
10311031
10321032 function getDeclarationDiagnostics ( sourceFile : SourceFile , cancellationToken : CancellationToken ) : Diagnostic [ ] {
1033- return getDiagnosticsHelper ( sourceFile , getDeclarationDiagnosticsForFile , cancellationToken ) ;
1033+ const options = program . getCompilerOptions ( ) ;
1034+ if ( ! sourceFile || options . out || options . outFile ) {
1035+ return getDeclarationDiagnosticsWorker ( sourceFile , cancellationToken ) ;
1036+ }
1037+ else {
1038+ return getDiagnosticsHelper ( sourceFile , getDeclarationDiagnosticsForFile , cancellationToken ) ;
1039+ }
10341040 }
10351041
10361042 function getSyntacticDiagnosticsForFile ( sourceFile : SourceFile , cancellationToken : CancellationToken ) : Diagnostic [ ] {
@@ -1244,17 +1250,19 @@ namespace ts {
12441250 } ) ;
12451251 }
12461252
1247- function getDeclarationDiagnosticsForFile ( sourceFile : SourceFile , cancellationToken : CancellationToken ) : Diagnostic [ ] {
1253+ function getDeclarationDiagnosticsWorker ( sourceFile : SourceFile , cancellationToken : CancellationToken ) : Diagnostic [ ] {
12481254 return runWithCancellationToken ( ( ) => {
1249- if ( ! isDeclarationFile ( sourceFile ) ) {
1250- const resolver = getDiagnosticsProducingTypeChecker ( ) . getEmitResolver ( sourceFile , cancellationToken ) ;
1251- // Don't actually write any files since we're just getting diagnostics.
1252- const writeFile : WriteFileCallback = ( ) => { } ;
1253- return ts . getDeclarationDiagnostics ( getEmitHost ( writeFile ) , resolver , sourceFile ) ;
1254- }
1255+ const resolver = getDiagnosticsProducingTypeChecker ( ) . getEmitResolver ( sourceFile , cancellationToken ) ;
1256+ // Don't actually write any files since we're just getting diagnostics.
1257+ const writeFile : WriteFileCallback = ( ) => { } ;
1258+ return ts . getDeclarationDiagnostics ( getEmitHost ( writeFile ) , resolver , sourceFile ) ;
12551259 } ) ;
12561260 }
12571261
1262+ function getDeclarationDiagnosticsForFile ( sourceFile : SourceFile , cancellationToken : CancellationToken ) : Diagnostic [ ] {
1263+ return isDeclarationFile ( sourceFile ) ? [ ] : getDeclarationDiagnosticsWorker ( sourceFile , cancellationToken ) ;
1264+ }
1265+
12581266 function getOptionsDiagnostics ( ) : Diagnostic [ ] {
12591267 const allDiagnostics : Diagnostic [ ] = [ ] ;
12601268 addRange ( allDiagnostics , fileProcessingDiagnostics . getGlobalDiagnostics ( ) ) ;
0 commit comments