Skip to content

Commit

Permalink
Update TypeScriptInternals.getResolvedModule() for TypeScript 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
octogonz committed Oct 24, 2023
1 parent 1dc8d0e commit fe0d68b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apps/api-extractor/src/analyzer/ExportAnalyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export class ExportAnalyzer {
: undefined;

const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(
this._program,
importOrExportDeclaration.getSourceFile(),
moduleSpecifier,
mode
Expand Down Expand Up @@ -882,6 +883,7 @@ export class ExportAnalyzer {
)
: undefined;
const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(
this._program,
importOrExportDeclaration.getSourceFile(),
moduleSpecifier,
mode
Expand Down
11 changes: 8 additions & 3 deletions apps/api-extractor/src/analyzer/TypeScriptInternals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,19 @@ export class TypeScriptInternals {
* The compiler populates this cache as part of analyzing the source file.
*/
public static getResolvedModule(
program: ts.Program,
sourceFile: ts.SourceFile,
moduleNameText: string,
mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined
): ts.ResolvedModuleFull | undefined {
// Compiler internal:
// https://github.com/microsoft/TypeScript/blob/v4.7.2/src/compiler/utilities.ts#L161

return (ts as any).getResolvedModule(sourceFile, moduleNameText, mode);
// https://github.com/microsoft/TypeScript/blob/v5.3-beta/src/compiler/types.ts#L4678
const result: ts.ResolvedModuleWithFailedLookupLocations | undefined = (program as any).getResolvedModule(
sourceFile,
moduleNameText,
mode
);
return result?.resolvedModule;
}

/**
Expand Down

0 comments on commit fe0d68b

Please sign in to comment.