@@ -302,6 +302,8 @@ namespace ts {
302302
303303 /** If provided, used to resolve the module names, otherwise typescript's default module resolution */
304304 resolveModuleNames ?( moduleNames : string [ ] , containingFile : string , reusedNames ?: string [ ] ) : ResolvedModule [ ] ;
305+ /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
306+ resolveTypeReferenceDirectives ?( typeReferenceDirectiveNames : string [ ] , containingFile : string ) : ResolvedTypeReferenceDirective [ ] ;
305307
306308 /** Used to watch changes in source files, missing files needed to update the program or config file */
307309 watchFile ( path : string , callback : FileWatcherCallback , pollingInterval ?: number ) : FileWatcher ;
@@ -520,7 +522,10 @@ namespace ts {
520522 compilerHost . resolveModuleNames = host . resolveModuleNames ?
521523 ( ( moduleNames , containingFile , reusedNames ) => host . resolveModuleNames ( moduleNames , containingFile , reusedNames ) ) :
522524 ( ( moduleNames , containingFile , reusedNames ) => resolutionCache . resolveModuleNames ( moduleNames , containingFile , reusedNames ) ) ;
523- compilerHost . resolveTypeReferenceDirectives = resolutionCache . resolveTypeReferenceDirectives . bind ( resolutionCache ) ;
525+ compilerHost . resolveTypeReferenceDirectives = host . resolveTypeReferenceDirectives ?
526+ ( ( typeDirectiveNames , containingFile ) => host . resolveTypeReferenceDirectives ( typeDirectiveNames , containingFile ) ) :
527+ ( ( typeDirectiveNames , containingFile ) => resolutionCache . resolveTypeReferenceDirectives ( typeDirectiveNames , containingFile ) ) ;
528+ const userProvidedResolution = ! ! host . resolveModuleNames || ! ! host . resolveTypeReferenceDirectives ;
524529
525530 reportWatchDiagnostic ( Diagnostics . Starting_compilation_in_watch_mode ) ;
526531 synchronizeProgram ( ) ;
@@ -542,7 +547,8 @@ namespace ts {
542547 }
543548 }
544549
545- const hasInvalidatedResolution = resolutionCache . createHasInvalidatedResolution ( ) ;
550+ // All resolutions are invalid if user provided resolutions
551+ const hasInvalidatedResolution = resolutionCache . createHasInvalidatedResolution ( userProvidedResolution ) ;
546552 if ( isProgramUptoDate ( program , rootFileNames , compilerOptions , getSourceVersion , fileExists , hasInvalidatedResolution , hasChangedAutomaticTypeDirectiveNames ) ) {
547553 return program ;
548554 }
0 commit comments