@@ -297,8 +297,9 @@ namespace ts {
297
297
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
298
298
* is assumed to be the same as root directory of the project.
299
299
*/
300
- export function resolveTypeReferenceDirective ( typeReferenceDirectiveName : string , containingFile : string | undefined , options : CompilerOptions , host : ModuleResolutionHost , redirectedReference ?: ResolvedProjectReference , cache ?: TypeReferenceDirectiveResolutionCache , resolutionMode ?: SourceFile [ "impliedNodeFormat" ] ) : ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
301
- Debug . assert ( typeof typeReferenceDirectiveName === "string" , "Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself." ) ;
300
+ export function resolveTypeReferenceDirective ( typeReferenceDirectiveName : string | FileReference , containingFile : string | undefined , options : CompilerOptions , host : ModuleResolutionHost , redirectedReference ?: ResolvedProjectReference , cache ?: TypeReferenceDirectiveResolutionCache , resolutionMode ?: SourceFile [ "impliedNodeFormat" ] ) : ResolvedTypeReferenceDirectiveWithFailedLookupLocations {
301
+ resolutionMode = typeof typeReferenceDirectiveName !== "string" && typeReferenceDirectiveName . resolutionMode || resolutionMode ;
302
+ typeReferenceDirectiveName = typeof typeReferenceDirectiveName !== "string" ? typeReferenceDirectiveName . fileName : typeReferenceDirectiveName ;
302
303
const traceEnabled = isTraceEnabled ( options , host ) ;
303
304
if ( redirectedReference ) {
304
305
options = redirectedReference . commandLine . options ;
@@ -397,7 +398,7 @@ namespace ts {
397
398
trace ( host , Diagnostics . Resolving_with_primary_search_path_0 , typeRoots . join ( ", " ) ) ;
398
399
}
399
400
return firstDefined ( typeRoots , typeRoot => {
400
- const candidate = combinePaths ( typeRoot , typeReferenceDirectiveName ) ;
401
+ const candidate = combinePaths ( typeRoot , typeReferenceDirectiveName as string ) ;
401
402
const candidateDirectory = getDirectoryPath ( candidate ) ;
402
403
const directoryExists = directoryProbablyExists ( candidateDirectory , host ) ;
403
404
if ( ! directoryExists && traceEnabled ) {
@@ -424,12 +425,12 @@ namespace ts {
424
425
trace ( host , Diagnostics . Looking_up_in_node_modules_folder_initial_location_0 , initialLocationForSecondaryLookup ) ;
425
426
}
426
427
let result : Resolved | undefined ;
427
- if ( ! isExternalModuleNameRelative ( typeReferenceDirectiveName ) ) {
428
- const searchResult = loadModuleFromNearestNodeModulesDirectory ( Extensions . DtsOnly , typeReferenceDirectiveName , initialLocationForSecondaryLookup , moduleResolutionState , /*cache*/ undefined , /*redirectedReference*/ undefined ) ;
428
+ if ( ! isExternalModuleNameRelative ( typeReferenceDirectiveName as string ) ) {
429
+ const searchResult = loadModuleFromNearestNodeModulesDirectory ( Extensions . DtsOnly , typeReferenceDirectiveName as string , initialLocationForSecondaryLookup , moduleResolutionState , /*cache*/ undefined , /*redirectedReference*/ undefined ) ;
429
430
result = searchResult && searchResult . value ;
430
431
}
431
432
else {
432
- const { path : candidate } = normalizePathForCJSResolution ( initialLocationForSecondaryLookup , typeReferenceDirectiveName ) ;
433
+ const { path : candidate } = normalizePathForCJSResolution ( initialLocationForSecondaryLookup , typeReferenceDirectiveName as string ) ;
433
434
result = nodeLoadModuleByRelativeName ( Extensions . DtsOnly , candidate , /*onlyRecordFailures*/ false , moduleResolutionState , /*considerPackageJson*/ true ) ;
434
435
}
435
436
return resolvedTypeScriptOnly ( result ) ;
@@ -922,7 +923,9 @@ namespace ts {
922
923
return perFolderCache . get ( moduleName , mode ) ;
923
924
}
924
925
925
- export function resolveModuleName ( moduleName : string , containingFile : string , compilerOptions : CompilerOptions , host : ModuleResolutionHost , cache ?: ModuleResolutionCache , redirectedReference ?: ResolvedProjectReference , resolutionMode ?: ModuleKind . CommonJS | ModuleKind . ESNext ) : ResolvedModuleWithFailedLookupLocations {
926
+ export function resolveModuleName ( moduleName : string | FileReference , containingFile : string , compilerOptions : CompilerOptions , host : ModuleResolutionHost , cache ?: ModuleResolutionCache , redirectedReference ?: ResolvedProjectReference , resolutionMode ?: ModuleKind . CommonJS | ModuleKind . ESNext ) : ResolvedModuleWithFailedLookupLocations {
927
+ resolutionMode = typeof moduleName !== "string" && moduleName . resolutionMode || resolutionMode ;
928
+ moduleName = typeof moduleName !== "string" ? moduleName . fileName : moduleName ;
926
929
const traceEnabled = isTraceEnabled ( compilerOptions , host ) ;
927
930
if ( redirectedReference ) {
928
931
compilerOptions = redirectedReference . commandLine . options ;
0 commit comments