@@ -259,6 +259,7 @@ export interface ModuleResolutionState {
259
259
requestContainingDirectory : string | undefined ;
260
260
reportDiagnostic : DiagnosticReporter ;
261
261
isConfigLookup : boolean ;
262
+ suppressResolvedUsingTsExtension : boolean ;
262
263
}
263
264
264
265
/** Just the fields that we use for module resolution.
@@ -526,6 +527,7 @@ export function resolveTypeReferenceDirective(typeReferenceDirectiveName: string
526
527
requestContainingDirectory : containingDirectory ,
527
528
reportDiagnostic : diag => void diagnostics . push ( diag ) ,
528
529
isConfigLookup : false ,
530
+ suppressResolvedUsingTsExtension : false ,
529
531
} ;
530
532
let resolved = primaryLookup ( ) ;
531
533
let primary = true ;
@@ -1652,6 +1654,7 @@ function nodeModuleNameResolverWorker(features: NodeResolutionFeatures, moduleNa
1652
1654
requestContainingDirectory : containingDirectory ,
1653
1655
reportDiagnostic : diag => void diagnostics . push ( diag ) ,
1654
1656
isConfigLookup,
1657
+ suppressResolvedUsingTsExtension : false ,
1655
1658
} ;
1656
1659
1657
1660
if ( traceEnabled && getEmitModuleResolutionKind ( compilerOptions ) >= ModuleResolutionKind . Node16 && getEmitModuleResolutionKind ( compilerOptions ) <= ModuleResolutionKind . NodeNext ) {
@@ -1948,7 +1951,7 @@ function tryAddingExtensions(candidate: string, extensions: Extensions, original
1948
1951
1949
1952
function tryExtension ( ext : string , resolvedUsingTsExtension ?: boolean ) : PathAndExtension | undefined {
1950
1953
const path = tryFile ( candidate + ext , onlyRecordFailures , state ) ;
1951
- return path === undefined ? undefined : { path, ext, resolvedUsingTsExtension } ;
1954
+ return path === undefined ? undefined : { path, ext, resolvedUsingTsExtension : ! state . suppressResolvedUsingTsExtension && resolvedUsingTsExtension } ;
1952
1955
}
1953
1956
}
1954
1957
@@ -2111,6 +2114,7 @@ export function getTemporaryModuleResolutionState(packageJsonInfoCache: PackageJ
2111
2114
requestContainingDirectory : undefined ,
2112
2115
reportDiagnostic : noop ,
2113
2116
isConfigLookup : false ,
2117
+ suppressResolvedUsingTsExtension : false ,
2114
2118
} ;
2115
2119
}
2116
2120
@@ -2232,11 +2236,14 @@ function loadNodeModuleFromDirectoryWorker(extensions: Extensions, candidate: st
2232
2236
// (technically it only emits a deprecation warning in esm packages right now, but that's probably
2233
2237
// enough to mean we don't need to support it)
2234
2238
const features = state . features ;
2239
+ const suppressResolvedUsingTsExtension = state . suppressResolvedUsingTsExtension ;
2240
+ state . suppressResolvedUsingTsExtension = true ;
2235
2241
if ( jsonContent ?. type !== "module" ) {
2236
2242
state . features &= ~ NodeResolutionFeatures . EsmMode ;
2237
2243
}
2238
2244
const result = nodeLoadModuleByRelativeName ( expandedExtensions , candidate , onlyRecordFailures , state , /*considerPackageJson*/ false ) ;
2239
2245
state . features = features ;
2246
+ state . suppressResolvedUsingTsExtension = suppressResolvedUsingTsExtension ;
2240
2247
return result ;
2241
2248
} ;
2242
2249
@@ -2935,6 +2942,7 @@ export function classicNameResolver(moduleName: string, containingFile: string,
2935
2942
requestContainingDirectory : containingDirectory ,
2936
2943
reportDiagnostic : diag => void diagnostics . push ( diag ) ,
2937
2944
isConfigLookup : false ,
2945
+ suppressResolvedUsingTsExtension : false ,
2938
2946
} ;
2939
2947
2940
2948
const resolved =
@@ -3015,6 +3023,7 @@ export function loadModuleFromGlobalCache(moduleName: string, projectName: strin
3015
3023
requestContainingDirectory : undefined ,
3016
3024
reportDiagnostic : diag => void diagnostics . push ( diag ) ,
3017
3025
isConfigLookup : false ,
3026
+ suppressResolvedUsingTsExtension : false ,
3018
3027
} ;
3019
3028
const resolved = loadModuleFromImmediateNodeModulesDirectory ( Extensions . Declaration , moduleName , globalCache , state , /*typesScopeOnly*/ false , /*cache*/ undefined , /*redirectedReference*/ undefined ) ;
3020
3029
return createResolvedModuleWithFailedLookupLocations (
0 commit comments