rushstack
rushstack copied to clipboard
[api-extractor] fix namespace support
Summary
api-extractor generates invalid dts results for some namespace declaration cases. e.g.
- #4807
- #3127
- invalid dts results in current repo:
- https://github.com/microsoft/rushstack/blob/main/build-tests/api-extractor-scenarios/etc/apiItemKinds/rollup.d.ts#L31
- https://github.com/microsoft/rushstack/blob/main/build-tests/api-extractor-scenarios/etc/apiItemKinds/rollup.d.ts#L39
Details
Code changes summary:
-
Analyzing phase: analyze "export { A as B }" node (which should be referenced by namespace)
-
Emitting phase:
- fix export/default/declare modifier only for root declarations.
- when renaming Identifier node, fix a special case for "export { A }"
-
Fixed #4807
-
Fixed #3127
-
Fix unexpected export of actual un-exported declaration: input:
export namespace PartalExportedNS { interface UnexportedClass { } export interface ExportedInterface { prop: UnexportedClass; } }expected output:
export declare namespace PartalExportedNS { interface UnexportedClass { } export interface ExportedInterface { prop: UnexportedClass; } export { }; } export { }actual output:
export declare namespace PartalExportedNS { // This should not be exported export interface UnexportedClass { } export interface ExportedInterface { prop: UnexportedClass; } { }; } export { }
How it was tested
Added a new namespaceDeclaration test case, and verified other test results.
Impacted documentation
@adventure-yunfei Thanks for this fix!
Overall it looks good to me. I will merge it after testing.