-
Notifications
You must be signed in to change notification settings - Fork 647
Description
Summary
when using together with manual import, import() syntax may generate invalid dts rollup result.
Repro steps
run dts rollup with following dts input file:
import { FooModule } from 'foo';
export interface Foo {
prop: FooModule.FooClass;
prop_importType: import('foo').FooModule.FooClass;
}
export {}
Expected result:
Generate dts rollup result:
import { FooModule } from 'foo';
export declare interface Foo {
prop: FooModule.FooClass;
prop_importType: FooModule.FooClass;
}
export { }
Actual result:
import { FooModule } from 'foo';
export declare interface Foo {
prop: FooModule.FooClass;
prop_importType: FooModule; // this should be FooModule.FooClass
}
export { }
Details
Found the reason after debug. When fetchAstImport, the result is cached by key from AstImport.getKey
. But AstImport with AstImportKind.ImportType type generates the same key with other type. So when both types exist in the dts file, they are all resolved to the same AstImport instance. And the import type mismatching will cause error. e.g. when emitting dts rollup, only AstImoprt with ImportType is handled for import()
syntax (in modifyImportTypeSpan
).
Maybe we should ensure that the same cache key always refers to the same result.
Standard questions
Please answer these questions to help us investigate your issue more quickly:
Question | Answer |
---|---|
@microsoft/api-extractor version? |
7.52.11 |
Operating system? | Mac |
API Extractor scenario? | rollups (.d.ts) |
Would you consider contributing a PR? | Yes |
TypeScript compiler version? | 5.8.2 |
Node.js version (node -v )? |
v16.20.0 |
Metadata
Metadata
Assignees
Labels
Type
Projects
Status