Skip to content

typescript-public-api: entry points use the nearest tsconfig, so paths apply - #350

Merged
agorischek merged 4 commits into
mainfrom
agorischek-studious-disco-paths
Dec 4, 2026
Merged

agorischek merged 4 commits into
mainfrom
agorischek-studious-disco-paths

Conversation

@agorischek

@agorischek agorischek commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

What changed

Two bug fixes for typescript-public-api, from more setup trials on real monorepos:

  • paths aliases with entry points only. A CLI package's sources import each other through a tsconfig paths alias ("@/*": ["./src/*"] with baseUrl: "."). With inputs.entrypoints set and no inputs.tsconfig, which is the workaround the extractor's own errors suggest, the program used generic default options instead of the package's tsconfig. Every alias then failed with TS2307. When no tsconfig is selected, each entry point now uses the nearest tsconfig.json above it, as an editor does. Without entry points, or with none above them, it still falls back to the root tsconfig.json or the default program.

  • typesVersions ranges. typescript-public-api: entry points from unbuilt output, composite projects and ambient declarations #336's range reader understood comparators and || but not ^5.0, ~5.9 or 5.0 - 5.9. A table keyed that way was skipped, and a later table could supply a different source. It now reads the compiler's range grammar. The same fix to explore's reader is in explore: propose typescript-public-api with the right tsconfig, entry points, timeout and needs #339.

  • Entry points in the advice. A package tsconfig that includes tests or scripts with a lib or rootDir they don't fit failed every extraction. Setting inputs.entrypoints fixes it, but only unresolved modules got that advice. Any analysis failure without entry points now suggests them, with an example.

  • Ownership (review). Each entry point is checked under its own nearest tsconfig only: a root tsconfig that also includes the package, without its paths, no longer checks it. An entry point without a tsconfig above it gets the default options, not the first package's.

The type-error policy change from the same trial evidence is in a separate PR, held for the owner.

Evidence

  • npm run tools -- check --fast: considered, lint, typecheck and changelog pass. format fails only on docs/guides/host-core.md and tools/scripts/check-styles.mjs, which already fail on main and aren't touched here.

  • npm run tools -- test packages/extractors/typescript-support: pass (54 tests).

  • The new tests fail on the source before each fix: "entry points without a tsconfig use the nearest one, with its paths" (TS2307 for @/commands/config) "typesVersions ranges read as the compiler reads them", "each entry point is checked under its own nearest tsconfig only, or the defaults without one" (TS2307 under the root tsconfig), and "a tsconfig broader than the entry points fails with the advice to name them".

  • Documentation that this change affects is updated, and generated reference
    pages are regenerated (npm run docs:generate).

  • Fixes include a regression test.

  • A changelog fragment at changelog.d/<this PR's number>.md describes what
    users will notice, or the PR has the no changelog label (see
    changelog.d/README.md).

  • No credentials, private source or machine-specific paths are included.

agorischek and others added 2 commits December 4, 2026 09:03
…s apply

With inputs.entrypoints and no inputs.tsconfig, the program used generic
default options, so tsconfig paths aliases (`@/commands/config`) didn't
resolve. Each entry point now takes the nearest tsconfig.json above it, as
an editor does. typesVersions ranges also read caret, tilde and hyphen
forms, so the table the compiler would apply is the one used.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Configuration ownership is lost during program construction, causing alias resolution failures with overlapping configs and incorrect option inheritance for entries without an ancestor config.

1 open issue
What changed in this PR

Improves typescript-public-api configuration discovery and typesVersions matching for monorepos.

Changes:

  • Finds the nearest tsconfig for explicitly supplied entry points.
  • Adds caret, tilde, and hyphen version-range support.
  • Adds regression tests, documentation, and a changelog entry.
File Description
packages/​extractors/​typescript-support/​test/​collectors-typescript.test.ts Tests alias resolution and version ranges.
packages/​extractors/​typescript-support/​src/​typescript/​versions.ts Expands supported range syntax.
packages/​extractors/​typescript-support/​src/​typescript/​project.ts Discovers entry points’ nearest tsconfigs.
packages/​extractors/​typescript-public-api/​README.md Documents automatic tsconfig selection.
docs/​builtins/​extractors/​typescript-public-api.md Updates configuration reference documentation.
changelog.d/​350.md Records both extractor fixes.

Review effort: Balanced

agorischek and others added 2 commits December 4, 2026 09:25
An entry point belongs to the nearest tsconfig.json above it: another
selected tsconfig that also includes it (a root one without the package's
paths) no longer checks it, and an entry point without one gets the
default options rather than the first package's.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
A package tsconfig that includes tests or scripts (with a lib or rootDir
they don't fit) failed every extraction, and only unresolved modules got
the advice to set inputs.entrypoints. Any analysis failure without entry
points now suggests them.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
@agorischek
agorischek merged commit 5d18683 into main Dec 4, 2026
34 checks passed
@agorischek
agorischek deleted the agorischek-studious-disco-paths branch December 4, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants