Skip to content
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] Unused import statements not trimmed --> causing errors when consuming rollup file #3094

Open
AvatharDG opened this issue Dec 15, 2021 · 4 comments
Labels
bug Something isn't working as intended

Comments

@AvatharDG
Copy link

Summary

When trimming certain members during rollup (e.g. removing interfaces/classes), related import statements at the top of the rollup file are not trimmed, when they are no longer needed.

Repro steps

I have two libraries library-a and library-b.

They have some internal members (decorated with @internal comment), which I want to remove in a public distributable version. Library-b is extending some internal members of library-a.

The public trimmed rollup of library-b however remains with some import statements to internals of library-a.

Since they are no longer exported, this results in "Module library-a has no exported member xxxx" when consuming both public versions of these libraries.

Possible solution

It would help if api-extractor would remove any unused import statements when all processing is done.

Example

library-a.d.ts (untrimmed):

/**
 * @internal
 */
export declare interface _InterfaceA {
}

library-b.d.ts (untrimmed):

import { _InterfaceA } from 'library-a';

/**
 * @internal
 */
export declare interface _InterfaceB extends _InterfaceA {
}

library-b.public.d.ts (trimmed):

import { _InterfaceA } from 'library-a'; --> this line should be removed

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/api-extractor version? 7.19.2
Operating system? Windows
API Extractor scenario? rollups (.d.ts) -->
Would you consider contributing a PR? Maybe
TypeScript compiler version? 4.5.3
Node.js version (node -v)?
@j-ulrich
Copy link

Note that a similar issue also exists for export of @internal APIs. See #2791.

@akania
Copy link

akania commented Aug 16, 2023

+1 to fix this please

@sharifrahaman
Copy link

Plese fix this issue.

@vamshich13
Copy link

please fix this

@octogonz octogonz added the bug Something isn't working as intended label Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as intended
Projects
Status: AE/AD
Development

No branches or pull requests

6 participants