File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -98,17 +98,16 @@ export function createResolverFunctions(kwargs: {
9898 optionsOnlyWithNewerTsVersions : TSCommon . CompilerOptions ,
9999 containingSourceFile ?: TSCommon . SourceFile
100100 ) : ( TSCommon . ResolvedModule | undefined ) [ ] => {
101- return moduleNames . map ( ( moduleName ) => {
101+ return moduleNames . map ( ( moduleName , i ) => {
102+ const mode = containingSourceFile ? ( ts as any as TSInternal ) . getModeForResolutionAtIndex ?.( containingSourceFile , i ) : undefined ;
102103 const { resolvedModule } = ts . resolveModuleName (
103104 moduleName ,
104105 containingFile ,
105106 config . options ,
106107 host ,
107108 moduleResolutionCache ,
108109 redirectedReference ,
109- containingSourceFile ?. impliedNodeFormat
110-
111- // (ts as any as typeof import('typescript')).getModeForResolutionAtIndex(containingSourceFile)
110+ mode ,
112111 ) ;
113112 if ( resolvedModule ) {
114113 fixupResolvedModule ( resolvedModule ) ;
Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ export interface TSInternal {
117117 basePath : string ,
118118 usage : 'files' | 'directories' | 'exclude'
119119 ) : string | undefined ;
120+ // Added in TS 4.7
121+ getModeForResolutionAtIndex ?( file : TSInternal . SourceFileImportsList , index : number ) : _ts . SourceFile [ 'impliedNodeFormat' ] ;
120122}
121123/** @internal */
122124export namespace TSInternal {
@@ -127,4 +129,8 @@ export namespace TSInternal {
127129 getCurrentDirectory ( ) : string ;
128130 useCaseSensitiveFileNames : boolean ;
129131 }
132+ // Note: is only a partial declaration, TS sources declare other fields
133+ export interface SourceFileImportsList {
134+ impliedNodeFormat ?: TSCommon . SourceFile [ "impliedNodeFormat" ] ;
135+ } ;
130136}
You can’t perform that action at this time.
0 commit comments