@@ -68,6 +68,7 @@ import {
6868 EmitHost ,
6969 emitModuleKindIsNonNodeESM ,
7070 EmitOnly ,
71+ emitResolverSkipsTypeChecking ,
7172 EmitResult ,
7273 emptyArray ,
7374 ensureTrailingDirectorySeparator ,
@@ -2870,18 +2871,27 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
28702871 // This is because in the -out scenario all files need to be emitted, and therefore all
28712872 // files need to be type checked. And the way to specify that all files need to be type
28722873 // checked is to not pass the file to getEmitResolver.
2873- const emitResolver = getTypeChecker ( ) . getEmitResolver ( options . outFile ? undefined : sourceFile , cancellationToken ) ;
2874+ const typeChecker = getTypeChecker ( ) ;
2875+ const emitResolver = typeChecker . getEmitResolver (
2876+ options . outFile ? undefined : sourceFile ,
2877+ cancellationToken ,
2878+ emitResolverSkipsTypeChecking ( emitOnly , forceDtsEmit ) ,
2879+ ) ;
28742880
28752881 performance . mark ( "beforeEmit" ) ;
28762882
2877- const emitResult = emitFiles (
2878- emitResolver ,
2879- getEmitHost ( writeFileCallback ) ,
2880- sourceFile ,
2881- getTransformers ( options , customTransformers , emitOnly ) ,
2882- emitOnly ,
2883- /*onlyBuildInfo*/ false ,
2884- forceDtsEmit ,
2883+ const emitResult = typeChecker . runWithCancellationToken (
2884+ cancellationToken ,
2885+ ( ) =>
2886+ emitFiles (
2887+ emitResolver ,
2888+ getEmitHost ( writeFileCallback ) ,
2889+ sourceFile ,
2890+ getTransformers ( options , customTransformers , emitOnly ) ,
2891+ emitOnly ,
2892+ /*onlyBuildInfo*/ false ,
2893+ forceDtsEmit ,
2894+ ) ,
28852895 ) ;
28862896
28872897 performance . mark ( "afterEmit" ) ;
0 commit comments