Repository navigation
[api-extractor] Prune unused imports from trimmed declaration rollups - #6240
Open
Ian Clanton-Thuon (iclanton) wants to merge 1 commit into
Open
Ian Clanton-Thuon (iclanton) wants to merge 1 commit into
Ian Clanton-Thuon (iclanton) wants to merge 1 commit into
Conversation
Track imports referenced by retained declarations and re-exports. Keep imports used by surviving signatures regardless of the imported release tag, and leave the untrimmed rollup unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consumers should not need to install an optional dependency just to type-check a package whose released declarations never use it. Omit imports used only by declarations removed from an alpha, beta, or public
.d.tsrollup.Fixes #4260.
Details
Track which import bindings are actually used while emitting surviving declarations and re-exports, including inline
import()types and namespace exports. Emit those imports before the declarations in their existing order. A retained signature still gets its import even if the imported symbol has a less-public release tag. The untrimmed rollup and release-tag semantics are unchanged.How it was tested
rush --quiet build -o @microsoft/api-extractor -o api-extractor-scenarios --productionpasses on the PR commit.rush change --verify --target-branch microsoft/main --no-fetchpasses.