Fix: prune unreachable definitions when --type "*" is used with multiple exports#2284
Merged
arthurfiorette merged 10 commits intovega:nextfrom Jun 22, 2025
Merged
Conversation
type: "*" is used and there is more than one export in the main file--type "*" is used with multiple exports
arthurfiorette
approved these changes
Jun 19, 2025
arthurfiorette
requested changes
Jun 19, 2025
arthurfiorette
requested changes
Jun 20, 2025
arthurfiorette
requested changes
Jun 20, 2025
arthurfiorette
requested changes
Jun 20, 2025
arthurfiorette
approved these changes
Jun 22, 2025
This was referenced Nov 30, 2025
This was referenced Nov 30, 2025
Merged
Merged
|
🚀 PR was released in |
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.
With
--type "*"(“export all”), the generator pruned unreachable definitions only when there was a single root export.If two or more symbols were exported from the entry file, every transitive reference of every root leaked into
definitions, producing a bloated schema.Consider this entry file that we export with
type: "*"(in test suite +mainTsOnly: true):main.tsThe resulting schema was:
schema.jsonSomeInterfacewas present even though it is not exported by the entry file.If we just comment out
export type MyType = string;:main.ts…the emitted schema no longer includes
SomeInterface:schema.jsonThis happened because
SchemaGenerator.createSchemaFromNodesfailed to pass any root definitions toremoveUnreachablewhen more than one export was present; it passedundefined, so the pruning step was skipped and every collected definition remained.Fix
In
SchemaGenerator.tswe now:removeUnreachablefor each root.Tests
Added fixture
export-star-prune-unreachablein thevalid-data-typesuite which confirms that only the entry-file exports are emitted; unrelated definitions are pruned.Impact
Output schemas are now minimal and deterministic when
"*"is used, no matter how many items are exported from the main file.No API changes.
Version
Published prerelease version:
v2.5.0-next.4Changelog
🎉 This release contains work from new contributors! 🎉
Thanks for all your work!
❤️ Alex (@alexchexes)
❤️ Valentyne Stigloher (@pixunil)
🚀 Enhancement
🐛 Bug Fix
--type "*"is used with multiple exports #2284 (@alexchexes @arthurfiorette)symbol#2282 (@alexchexes)🔩 Dependency Updates
Authors: 4