@@ -21,6 +21,7 @@ import {
2121 CallExpression ,
2222 CallSignatureDeclaration ,
2323 canHaveLocals ,
24+ canIncludeBindAndCheckDiagnsotics ,
2425 CaseBlock ,
2526 CaseClause ,
2627 CaseOrDefaultClause ,
@@ -800,9 +801,14 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi
800801 return ;
801802 }
802803
803- if ( compilerOptions . noCheck ) {
804- ( isSourceFile ( sourceFileOrBundle ) ? [ sourceFileOrBundle ] : filter ( sourceFileOrBundle . sourceFiles , isSourceFileNotJson ) ) . forEach ( markLinkedReferences ) ;
805- }
804+ ( isSourceFile ( sourceFileOrBundle ) ? [ sourceFileOrBundle ] : filter ( sourceFileOrBundle . sourceFiles , isSourceFileNotJson ) ) . forEach (
805+ sourceFile => {
806+ if (
807+ compilerOptions . noCheck ||
808+ ! canIncludeBindAndCheckDiagnsotics ( sourceFile , compilerOptions )
809+ ) markLinkedReferences ( sourceFile ) ;
810+ } ,
811+ ) ;
806812
807813 // Transform the source files
808814 const transform = transformNodes ( resolver , host , factory , compilerOptions , [ sourceFileOrBundle ] , scriptTransformers , /*allowDtsFiles*/ false ) ;
@@ -859,15 +865,19 @@ export function emitFiles(resolver: EmitResolver, host: EmitHost, targetSourceFi
859865 const filesForEmit = forceDtsEmit ? sourceFiles : filter ( sourceFiles , isSourceFileNotJson ) ;
860866 // Setup and perform the transformation to retrieve declarations from the input files
861867 const inputListOrBundle = compilerOptions . outFile ? [ factory . createBundle ( filesForEmit ) ] : filesForEmit ;
862- if (
863- ( emitOnly && ! getEmitDeclarations ( compilerOptions ) ) ||
864- compilerOptions . noCheck ||
865- emitResolverSkipsTypeChecking ( emitOnly , forceDtsEmit )
866- ) {
867- // Checker wont collect the linked aliases since thats only done when declaration is enabled and checking is performed.
868- // Do that here when emitting only dts files
869- filesForEmit . forEach ( collectLinkedAliases ) ;
870- }
868+ // Checker wont collect the linked aliases since thats only done when declaration is enabled and checking is performed.
869+ // Do that here when emitting only dts files
870+ filesForEmit . forEach ( sourceFile => {
871+ if (
872+ ( emitOnly && ! getEmitDeclarations ( compilerOptions ) ) ||
873+ compilerOptions . noCheck ||
874+ emitResolverSkipsTypeChecking ( emitOnly , forceDtsEmit ) ||
875+ ! canIncludeBindAndCheckDiagnsotics ( sourceFile , compilerOptions )
876+ ) {
877+ collectLinkedAliases ( sourceFile ) ;
878+ }
879+ } ) ;
880+
871881 const declarationTransform = transformNodes ( resolver , host , factory , compilerOptions , inputListOrBundle , declarationTransformers , /*allowDtsFiles*/ false ) ;
872882 if ( length ( declarationTransform . diagnostics ) ) {
873883 for ( const diagnostic of declarationTransform . diagnostics ! ) {
0 commit comments