Skip to content

Commit 18b51b5

Browse files
committed
add return type for getModeForUsageLocation
1 parent 9b25861 commit 18b51b5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

apps/api-extractor/src/analyzer/ExportAnalyzer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export class ExportAnalyzer {
262262
const specifier: ts.TypeNode | ts.Expression | undefined = ts.isImportTypeNode(importOrExportDeclaration)
263263
? importOrExportDeclaration.argument
264264
: importOrExportDeclaration.moduleSpecifier;
265-
const mode: ts.StringLiteralLike =
265+
const mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined =
266266
specifier && ts.isStringLiteralLike(specifier)
267267
? TypeScriptInternals.getModeForUsageLocation(importOrExportDeclaration.getSourceFile(), specifier)
268268
: undefined;
@@ -872,7 +872,7 @@ export class ExportAnalyzer {
872872
exportSymbol: ts.Symbol
873873
): AstModule {
874874
const moduleSpecifier: string = this._getModuleSpecifier(importOrExportDeclaration);
875-
const mode: ts.StringLiteralLike | undefined =
875+
const mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined =
876876
importOrExportDeclaration.moduleSpecifier &&
877877
ts.isStringLiteralLike(importOrExportDeclaration.moduleSpecifier)
878878
? TypeScriptInternals.getModeForUsageLocation(

apps/api-extractor/src/analyzer/TypeScriptInternals.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ export class TypeScriptInternals {
8484
public static getResolvedModule(
8585
sourceFile: ts.SourceFile,
8686
moduleNameText: string,
87-
mode: ts.StringLiteralLike | undefined
87+
mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined
8888
): ts.ResolvedModuleFull | undefined {
8989
// Compiler internal:
90-
// https://github.com/microsoft/TypeScript/blob/v3.2.2/src/compiler/utilities.ts#L218
90+
// https://github.com/microsoft/TypeScript/blob/v4.7.2/src/compiler/utilities.ts#L161
9191

9292
return (ts as any).getResolvedModule(sourceFile, moduleNameText, mode);
9393
}
@@ -97,12 +97,12 @@ export class TypeScriptInternals {
9797
*/
9898
public static getModeForUsageLocation(
9999
file: { impliedNodeFormat?: ts.SourceFile['impliedNodeFormat'] },
100-
usage: ts.StringLiteralLike
101-
) {
100+
usage: ts.StringLiteralLike | undefined
101+
): ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined {
102102
// Compiler internal:
103103
// https://github.com/microsoft/TypeScript/blob/v4.7.2/src/compiler/program.ts#L568
104104

105-
return (ts as any).getModeForUsageLocation(file, usage);
105+
return (ts as any).getModeForUsageLocation?.(file, usage);
106106
}
107107

108108
/**

0 commit comments

Comments
 (0)