@@ -185,6 +185,7 @@ const enum Extensions {
185
185
Json = 1 << 3 , // '.json'
186
186
187
187
ImplementationFiles = TypeScript | JavaScript ,
188
+ Any = ( TypeScript | JavaScript | Declaration | Json | 1 << 4 ) ,
188
189
}
189
190
190
191
function formatExtensions ( extensions : Extensions ) {
@@ -193,6 +194,7 @@ function formatExtensions(extensions: Extensions) {
193
194
if ( extensions & Extensions . JavaScript ) result . push ( "JavaScript" ) ;
194
195
if ( extensions & Extensions . Declaration ) result . push ( "Declaration" ) ;
195
196
if ( extensions & Extensions . Json ) result . push ( "JSON" ) ;
197
+ if ( extensions & Extensions . Any ) result . push ( "Any" ) ;
196
198
return result . join ( ", " ) ;
197
199
}
198
200
@@ -1772,7 +1774,7 @@ export function nodeModuleNameResolver(moduleName: string, containingFile: strin
1772
1774
export function nodeModuleNameResolver ( moduleName : string , containingFile : string , compilerOptions : CompilerOptions , host : ModuleResolutionHost , cache ?: ModuleResolutionCache , redirectedReference ?: ResolvedProjectReference , conditions ?: string [ ] , isConfigLookup ?: boolean ) : ResolvedModuleWithFailedLookupLocations {
1773
1775
let extensions ;
1774
1776
if ( isConfigLookup ) {
1775
- extensions = Extensions . Json ;
1777
+ extensions = Extensions . Any ;
1776
1778
}
1777
1779
else if ( compilerOptions . noDtsResolution ) {
1778
1780
extensions = Extensions . ImplementationFiles ;
@@ -1788,8 +1790,8 @@ export function nodeModuleNameResolver(moduleName: string, containingFile: strin
1788
1790
}
1789
1791
1790
1792
/** @internal */
1791
- export function nodeNextJsonConfigResolver ( moduleName : string , containingFile : string , host : ModuleResolutionHost ) : ResolvedModuleWithFailedLookupLocations {
1792
- return nodeModuleNameResolverWorker ( NodeResolutionFeatures . NodeNextDefault , moduleName , getDirectoryPath ( containingFile ) , { moduleResolution : ModuleResolutionKind . NodeNext } , host , /*cache*/ undefined , Extensions . Json , /*isConfigLookup*/ true , /*redirectedReference*/ undefined , /*conditions*/ undefined ) ;
1793
+ export function nodeNextTsconfigResolver ( moduleName : string , containingFile : string , host : ModuleResolutionHost ) : ResolvedModuleWithFailedLookupLocations {
1794
+ return nodeModuleNameResolverWorker ( NodeResolutionFeatures . NodeNextDefault , moduleName , getDirectoryPath ( containingFile ) , { moduleResolution : ModuleResolutionKind . NodeNext } , host , /*cache*/ undefined , Extensions . Any , /*isConfigLookup*/ true , /*redirectedReference*/ undefined , /*conditions*/ undefined ) ;
1793
1795
}
1794
1796
1795
1797
function nodeModuleNameResolverWorker (
@@ -2111,9 +2113,9 @@ function loadFileNameFromPackageJsonField(extensions: Extensions, candidate: str
2111
2113
return result !== undefined ? { path : candidate , ext, resolvedUsingTsExtension : packageJsonValue ? ! endsWith ( packageJsonValue , ext ) : undefined } : undefined ;
2112
2114
}
2113
2115
2114
- if ( state . isConfigLookup && extensions === Extensions . Json && fileExtensionIs ( candidate , Extension . Json ) ) {
2116
+ if ( state . isConfigLookup && ( extensions === Extensions . Any || extensionsToExtensionsArray ( extensions ) . some ( ext => fileExtensionIs ( candidate , ext ) ) ) ) {
2115
2117
const result = tryFile ( candidate , onlyRecordFailures , state ) ;
2116
- return result !== undefined ? { path : candidate , ext : Extension . Json , resolvedUsingTsExtension : undefined } : undefined ;
2118
+ return result !== undefined ? { path : candidate , ext : getAnyExtensionFromPath ( candidate ) , resolvedUsingTsExtension : undefined } : undefined ;
2117
2119
}
2118
2120
2119
2121
return loadModuleFromFileNoImplicitExtensions ( extensions , candidate , onlyRecordFailures , state ) ;
@@ -2168,6 +2170,7 @@ function tryAddingExtensions(candidate: string, extensions: Extensions, original
2168
2170
|| undefined ;
2169
2171
default :
2170
2172
return extensions & Extensions . Declaration && ! isDeclarationFileName ( candidate + originalExtension ) && tryExtension ( `.d${ originalExtension } .ts` )
2173
+ || extensions & Extensions . Any && tryExtension ( originalExtension )
2171
2174
|| undefined ;
2172
2175
}
2173
2176
0 commit comments