Repository navigation
typescript: a dependency staged with --library keeps the declarations under its build directory - #1941
Merged
swapnilpaliwal-sd merged 1 commit intoOct 13, 2026
Conversation
… under its build directory A library root was walked with the project skip list, so dist/, build/ and out/ were skipped. A package whose root .d.ts re-exports ./dist/... staged only the root files, and a package whose every declaration sits under dist/types/ was not detected as TypeScript at all. Every TypeScript call into such a package stayed ambiguous_unknown although it was passed with --library. The TypeScript analyzer now takes libraryRoot (as the JavaScript one does), and a library walk keeps the build-output directories. A library root that no detector calls TypeScript but whose package.json declares types (types/typings, or a types condition in exports) is analysed as one. The project under analysis is unchanged: dist/ stays skipped. Two discovery checks, each with a control: a re-exporting package as library vs as project, and a dist-only typed package vs an untyped one. Co-authored-by: axiomcode-bot[bot] <334110751+axiomcode-bot[bot]@users.noreply.github.com>
swapnilpaliwal-sd
requested review from
JaredHLZhang,
Whua689 and
suyashpaliwal26
as code owners
October 13, 2026 05:49
This was referenced Oct 13, 2026
Closed
Merged
Merged
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.
Symptom
A TypeScript call into a package passed with
--librarystaysambiguous_unknownwhen the package keeps its declarations in a build directory:.d.tsthat re-exports./dist/...: only the root files were staged (one measured package: 78 methods of ~1,600 declaration files);dist/types/(reached through anexportsmaptypescondition): no TypeScript was staged at all (0 methods), only its JavaScript.Cause
The TypeScript analyzer walked a library root with the project skip list (
dist,build,out), and detection looks for TypeScript near the top of the tree. JavaScript already distinguishes a library root (libraryRoot); TypeScript did not.Change
TypeScriptAnalysisOptions.libraryRoot;extractProjectpassesopts.library === true. A library walk keepsTS_BUILD_OUTPUT_DIRECTORIES; nestednode_modulesstays skipped.package.jsondeclares types (types/typings, or atypescondition anywhere inexports) is analysed as a TypeScript project.Evidence
.d.tsre-exporting./distdist/typesOn a 5-file client fixture with the libraries staged, four previously unresolved calls now resolve to library declarations (
boundary_lib); unknown sites 22 → 17. The remaining unknowns are other constructs (a default import re-exported as named, a namespace re-exported throughexport { z }, a method on an awaited return value, a library component used as a JSX element) and are not addressed here.Tests
a-library-keeps-the-declarations-under-its-build-directory(control: the same tree as the project still skipsdist/) anda-library-whose-declarations-all-sit-in-dist-is-typescript(control: an untyped package gets notypescript/). Both fail without the change.typescript-tests.ts49/49;tsc --noEmitclean.Cost
A library whose build directory is large stages more declaration files (one package: ~2 min, unchanged, since its JavaScript under
dist/was already walked; the TypeScript IR is 74 MB next to 3.6 GB of JavaScript IR).🤖 Generated with Claude Code