Skip to content

refactor(astro): replace tsconfck with get-tsconfig#16433

Open
ocavue wants to merge 9 commits intowithastro:mainfrom
ocavue-forks:ocavue/get-tsconfig-4
Open

refactor(astro): replace tsconfck with get-tsconfig#16433
ocavue wants to merge 9 commits intowithastro:mainfrom
ocavue-forks:ocavue/get-tsconfig-4

Conversation

@ocavue
Copy link
Copy Markdown
Contributor

@ocavue ocavue commented Apr 21, 2026

Summary

Replaces the discontinued tsconfck dependency with get-tsconfig@5.0.0-beta.4 and jsonc-parser. This is a step forward to support TS 6.0 as tsconfck doesn't support TS 6 in its peerDep.

Closes #16385

Why beta

I need to use get-tsconfig v5 beta instead of the v4 stable because get-tsconfig v4 leaks a feature that resolves all extended file paths for the purpose of dev server watch files (see privatenumber/get-tsconfig#119).

If astro team doesn't want to ship a beta dependency, we can wait for the get-tsconfig v5 stable.

What's changed

  1. Use jsonc-parser to parse the raw tsconfig file
  2. Use get-tsconfig to resolve the tsconfig (i.e., merge extends) and get a list of all files from extends.
  3. Remove 'unknown-error' error type
  4. Print the error message via logger if failed to parse the tsconfig file.

Notes for maintainers

  • get-tsconfig is pinned to exactly 5.0.0-beta.4 (no caret).
  • jsonc-parser is added as a direct dep. It was already transitively present via Vite, so no new bytes on disk.

Test

  1. Existing tests should pass
  2. Added two tests

Docs

Changeset added.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 21, 2026

⚠️ No Changeset found

Latest commit: d15b124

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release labels Apr 21, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@ocavue ocavue marked this pull request as ready for review April 21, 2026 06:38
@ocavue ocavue marked this pull request as draft April 21, 2026 06:40
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 21, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing ocavue-forks:ocavue/get-tsconfig-4 (d15b124) with main (1058428)

Open in CodSpeed

@ocavue ocavue force-pushed the ocavue/get-tsconfig-4 branch from 485c17f to 87dd769 Compare April 21, 2026 07:12
@github-actions github-actions Bot added pkg: integration Related to any renderer integration (scope) and removed pkg: integration Related to any renderer integration (scope) labels Apr 21, 2026
@ocavue ocavue force-pushed the ocavue/get-tsconfig-4 branch from d9ddf6f to a2c55af Compare April 21, 2026 07:55
compilerOptions?: StripEnums<CompilerOptions>;
compileOnSave?: boolean;
extends?: string;
extends?: string | string[];
Copy link
Copy Markdown
Contributor Author

@ocavue ocavue Apr 21, 2026

Choose a reason for hiding this comment

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

Note for reviewers:

extends can be an array since TS 5.0

*/
export async function loadTSConfig(
root: string | undefined,
findUp = false,
Copy link
Copy Markdown
Contributor Author

@ocavue ocavue Apr 21, 2026

Choose a reason for hiding this comment

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

Note for reviewers:

findUp is never passed; it was always false. I removed findUp in this PR.

tsconfigFile: normalize(resolved.path),
tsconfig: resolved.config satisfies TSConfig,
rawConfig,
sources: (resolved.sources || [resolved.path]).map(normalize),
Copy link
Copy Markdown
Contributor Author

@ocavue ocavue Apr 21, 2026

Choose a reason for hiding this comment

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

Note for reviewers:

Here I use normalize to return the backward slash \ on Windows. This aligns with the previous behavior. I don't see any issue with returning / on Windows, but it's good to be cautious just in case.

@ocavue ocavue force-pushed the ocavue/get-tsconfig-4 branch from 75707a9 to ceb6749 Compare April 21, 2026 09:03
@ocavue ocavue force-pushed the ocavue/get-tsconfig-4 branch from ceb6749 to 330a927 Compare April 21, 2026 10:17
@ocavue ocavue marked this pull request as ready for review April 21, 2026 11:42
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If there's no user facing change, we can skip the changeset

Copy link
Copy Markdown
Contributor Author

@ocavue ocavue Apr 22, 2026

Choose a reason for hiding this comment

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

deleted the changeset file

Copy link
Copy Markdown
Member

@delucis delucis left a comment

Choose a reason for hiding this comment

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

@ocavue Did you investigate the option of using the rolldown utilities as suggested in the tsconfck issue: dominikg/tsconfck#240? The issue links Vite’s PR where they did this: vitejs/vite#21577.

That would have to be against next where we have Vite 8 + Rolldown available but could be worth doing to avoid the extra dep. (If it covers everything we need — I haven’t looked yet, but I had it on my todo list.)

@ocavue
Copy link
Copy Markdown
Contributor Author

ocavue commented Apr 24, 2026

That's also on my todo list. I will check it out.

@ocavue
Copy link
Copy Markdown
Contributor Author

ocavue commented Apr 24, 2026

vite uses resolveTsconfig from rolldown/experimental to replace tsconfck.

I have two concerns about reusing this API in Astro:

  1. resolveTsconfig is marked as @hidden and noted as "only expected to be used by Vite". This suggests the Vite/Rolldown team may introduce breaking changes to this API even in a patch release.

  2. vite does not re-export resolveTsconfig. To use it, we would need to add rolldown as a direct dependency of astro. This could result in 2 different versions of rolldown in users'node_modules (e.g., astro -> rolldown and astro -> vite -> rolldown).

Copy link
Copy Markdown
Contributor

@Eveeifyeve Eveeifyeve left a comment

Choose a reason for hiding this comment

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

IA with #16433 (comment) I feel IMHO this change should be blocked until there is a clear more direction from the vite team.

joshka added a commit to ratatui/ratatui-website that referenced this pull request Apr 27, 2026
## Summary

- resolves TypeScript from 5.9.2 to 5.9.3 in `pnpm-lock.yaml`
- keeps the existing `package.json` range on TypeScript 5 so Astro
tooling remains inside its declared peer dependency support

## Why not TypeScript 6 yet?

TypeScript 6 is the npm latest, but it is a real migration release
rather than a routine patch update. The TypeScript 6 notes call out
changed compiler defaults, root directory behavior, stricter side-effect
import handling, deprecated options, and other migration concerns.

Astro support is also still catching up:

- withastro/astro#16112 tracks `@astrojs/check@0.9.8` still requiring
`typescript@^5.0.0`.
- withastro/astro#16385 tracks Astro still depending on `tsconfck`,
which also declares `typescript@^5.0.0` and is being discontinued.
- withastro/astro#16433 is the open upstream PR to replace `tsconfck`
with `get-tsconfig`; it is not merged yet.

Keeping this PR to TypeScript 5.9.3 gets the latest supported 5.x patch
without opting into peer dependency overrides or upstream compatibility
assumptions.

## Validation

- `mise exec -- corepack pnpm install --frozen-lockfile`
- `mise exec -- corepack pnpm test -- --run`
- `mise exec -- corepack pnpm format:check`
- `mise run build`
@dominikg
Copy link
Copy Markdown
Contributor

i think it makes sense for vite to expose it and started a feature request here
vitejs/vite#22336 please add any relevant information of apis you want/need, things like shared caching or change detection come to my mind but not intimately familiar with astro or its needs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsconfck is being discontinued, the new recommended way is to use get-tsconfig.

5 participants