fix(cli): support tsconfig without baseUrl#566
Open
tobigumo wants to merge 2 commits intochakra-ui:mainfrom
Open
fix(cli): support tsconfig without baseUrl#566tobigumo wants to merge 2 commits intochakra-ui:mainfrom
baseUrl#566tobigumo wants to merge 2 commits intochakra-ui:mainfrom
Conversation
TypeScript 6.0 deprecates `compilerOptions.baseUrl` and it is scheduled for removal in TypeScript 7. Previously the CLI required `baseUrl` in the user's tsconfig.json and would fail schema validation otherwise. Make `baseUrl` optional in the schema and fall back to the directory containing the resolved tsconfig.json, which matches TypeScript's own behavior when `paths` is specified without `baseUrl`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When `baseUrl` is absent, projects commonly add `"*": ["./*"]` to `paths` so that bare imports like `styled-system` keep resolving. The alias-prefix detector iterated all `paths` entries and picked the `"*"` catch-all first, producing a prefix of `"*"` and writing paths like `*/components` into components.json. Filter out the `"*"` catch-all and any entry whose key does not end in `/*`, so only real user aliases (`~/*`, `@/*`, ...) are considered. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.
Summary
@park-ui/clicurrently fails when the user'stsconfig.jsonhas nocompilerOptions.baseUrl. This PR lifts that requirement while preserving full backwards compatibility.Context
TypeScript 6.0 (GA) deprecates
baseUrl; TypeScript 7 removes it (already rejected by@typescript/native-preview/tsgo). The recommended migration is to dropbaseUrland rely onpathsalone, optionally with"*": ["./*"]for bare imports such asstyled-system.Refs #549, #540.
Changes
Two independent commits:
fix(cli): make tsconfig baseUrl optionalbaseUrlbecomes optional in the schema. When absent, the CLI falls back topath.dirname(tsconfigFile), matching TypeScript's ownpathsresolution behavior (TS 4.1+). UsestsconfigFilealready returned bytsconfck.parse(); no new dependency.fix(cli): ignore "*" catch-all path when detecting alias prefixWith
baseUrloptional, users commonly add"*": ["./*"]for bare imports. The previousgetTsConfigAliasPrefixpicked this catch-all as the alias prefix, producing paths like*/componentsincomponents.json. The detector now ignores"*"and any key not ending in/*, so only real aliases (~/*,@/*, …) are considered.Backwards compatibility
Projects with
baseUrldefined behave identically. Only configurations that previously failed now work.Test plan
bun run build,bun run lint,bunx tsc --noEmitinpackages/cli— no new errors in touched files (pre-existingmagicast/helpersresolution error inpanda-config.tsis unrelated to this PR).baseUrl: "."+paths: { "~/*": ["./src/*"] }→ generates intosrc/*(unchanged).baseUrl+paths: { "*": ["./*"], "~/*": ["./app/*"] }→ generates intoapp/*(previously failed or wrote to*/theme).🤖 Generated with Claude Code