Repository navigation
typescript-public-api: entry points use the nearest tsconfig, so paths apply - #350
Merged
Merged
Conversation
…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>
There was a problem hiding this comment.
🟡 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
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>
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.

What changed
Two bug fixes for
typescript-public-api, from more setup trials on real monorepos:pathsaliases with entry points only. A CLI package's sources import each other through a tsconfigpathsalias ("@/*": ["./src/*"]withbaseUrl: "."). Withinputs.entrypointsset and noinputs.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 nearesttsconfig.jsonabove it, as an editor does. Without entry points, or with none above them, it still falls back to the roottsconfig.jsonor the default program.typesVersionsranges. 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.9or5.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
liborrootDirthey don't fit failed every extraction. Settinginputs.entrypointsfixes 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.formatfails only ondocs/guides/host-core.mdandtools/scripts/check-styles.mjs, which already fail onmainand 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>.mddescribes whatusers will notice, or the PR has the
no changeloglabel (seechangelog.d/README.md).
No credentials, private source or machine-specific paths are included.