Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cspotcode committed Jun 1, 2022
1 parent c60ce01 commit 2e94032
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/resolver-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,16 @@ export function createResolverFunctions(kwargs: {
optionsOnlyWithNewerTsVersions: TSCommon.CompilerOptions,
containingSourceFile?: TSCommon.SourceFile
): (TSCommon.ResolvedModule | undefined)[] => {
return moduleNames.map((moduleName) => {
return moduleNames.map((moduleName, i) => {
const mode = containingSourceFile ? (ts as any as TSInternal).getModeForResolutionAtIndex?.(containingSourceFile, i) : undefined;
const { resolvedModule } = ts.resolveModuleName(
moduleName,
containingFile,
config.options,
host,
moduleResolutionCache,
redirectedReference,
containingSourceFile?.impliedNodeFormat

// (ts as any as typeof import('typescript')).getModeForResolutionAtIndex(containingSourceFile)
mode,
);
if (resolvedModule) {
fixupResolvedModule(resolvedModule);
Expand Down
6 changes: 6 additions & 0 deletions src/ts-compiler-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export interface TSInternal {
basePath: string,
usage: 'files' | 'directories' | 'exclude'
): string | undefined;
// Added in TS 4.7
getModeForResolutionAtIndex?(file: TSInternal.SourceFileImportsList, index: number): _ts.SourceFile['impliedNodeFormat'];
}
/** @internal */
export namespace TSInternal {
Expand All @@ -127,4 +129,8 @@ export namespace TSInternal {
getCurrentDirectory(): string;
useCaseSensitiveFileNames: boolean;
}
// Note: is only a partial declaration, TS sources declare other fields
export interface SourceFileImportsList {
impliedNodeFormat?: TSCommon.SourceFile["impliedNodeFormat"];
};
}

0 comments on commit 2e94032

Please sign in to comment.