-
Notifications
You must be signed in to change notification settings - Fork 616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[api-extractor] building with TS 5.6.2 causes error on wildcard import #4919
Comments
We also have a reproduction over in typescript-eslint: https://github.com/typescript-eslint/typescript-eslint/pull/9972/files. |
Thanks for providing a repro. I am on a business trip but will take a look when I get a chance. |
@octogonz-dev sorry for bothering you, but this is blocking us in typescript-ealint - is there anything we can do to help? |
Will this be fixed soon? Looks like typescript-eslint cannot support TypeScript 5.6 until this has been fixed. |
microsoft/TypeScript#58825 was the PR which made api-extractor stop working; api-extractor reaches into TS internals, so this isn't super surprising. $ every-ts switch a9139bfdfea154dfa9cc97f465c933ee02b3fcfa~1
$ yarn build
api-extractor 7.47.8 - https://api-extractor.com/
Using configuration from ./api-extractor.json
Analysis will use the bundled TypeScript version 5.6.0-dev
API Extractor completed successfully
$ every-ts switch a9139bfdfea154dfa9cc97f465c933ee02b3fcfa
$ yarn build
api-extractor 7.47.8 - https://api-extractor.com/
Using configuration from ./api-extractor.json
Analysis will use the bundled TypeScript version 5.6.0-dev
ERROR: Internal Error: getResolvedModule() could not resolve module name "./ast-node-types"
/home/jabaile/work/TypeScript-eslint/packages/ast-spec/dist/index.d.ts:1:1
You have encountered a software defect. Please consider reporting the issue to the maintainers of this application. I have not debugged past this. |
This diff was enough to make ts-eslint not crash: diff --git a/apps/api-extractor/src/analyzer/ExportAnalyzer.ts b/apps/api-extractor/src/analyzer/ExportAnalyzer.ts
index 5268cc8eb1..d1fdc103f2 100644
--- a/apps/api-extractor/src/analyzer/ExportAnalyzer.ts
+++ b/apps/api-extractor/src/analyzer/ExportAnalyzer.ts
@@ -265,7 +265,7 @@ export class ExportAnalyzer {
: importOrExportDeclaration.moduleSpecifier;
const mode: ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined =
specifier && ts.isStringLiteralLike(specifier)
- ? TypeScriptInternals.getModeForUsageLocation(importOrExportDeclaration.getSourceFile(), specifier)
+ ? TypeScriptInternals.getModeForUsageLocation(importOrExportDeclaration.getSourceFile(), specifier, this._program.getCompilerOptions())
: undefined;
const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(
@@ -905,7 +905,8 @@ export class ExportAnalyzer {
ts.isStringLiteralLike(importOrExportDeclaration.moduleSpecifier)
? TypeScriptInternals.getModeForUsageLocation(
importOrExportDeclaration.getSourceFile(),
- importOrExportDeclaration.moduleSpecifier
+ importOrExportDeclaration.moduleSpecifier,
+ this._program.getCompilerOptions()
)
: undefined;
const resolvedModule: ts.ResolvedModuleFull | undefined = TypeScriptInternals.getResolvedModule(
diff --git a/apps/api-extractor/src/analyzer/TypeScriptInternals.ts b/apps/api-extractor/src/analyzer/TypeScriptInternals.ts
index eeb8e1b4df..6c48447cef 100644
--- a/apps/api-extractor/src/analyzer/TypeScriptInternals.ts
+++ b/apps/api-extractor/src/analyzer/TypeScriptInternals.ts
@@ -102,12 +102,13 @@ export class TypeScriptInternals {
*/
public static getModeForUsageLocation(
file: { impliedNodeFormat?: ts.SourceFile['impliedNodeFormat'] },
- usage: ts.StringLiteralLike | undefined
+ usage: ts.StringLiteralLike | undefined,
+ compilerOptions: ts.CompilerOptions
): ts.ModuleKind.CommonJS | ts.ModuleKind.ESNext | undefined {
// Compiler internal:
// https://github.com/microsoft/TypeScript/blob/v4.7.2/src/compiler/program.ts#L568
- return (ts as any).getModeForUsageLocation?.(file, usage);
+ return (ts as any).getModeForUsageLocation?.(file, usage, compilerOptions);
}
/** I have not validated that things still work. I'll also note that |
Sent #4973 |
❤ thanks @jakebailey! |
Summary
Trying to upgrade TS from 5.4.5 to 5.6.2
Somehow this causes api extractor to fail. I tried with the latest version as well as an older version.
Repro steps
pnpm api.update
See https://github.com/QwikDev/qwik/actions/runs/10813753964/job/29998536883?pr=6874#step:6:536
Details
It's failing on
But there's nothing special in the file it imports
Standard questions
Please answer these questions to help us investigate your issue more quickly:
@microsoft/api-extractor
version?node -v
)?The text was updated successfully, but these errors were encountered: