Repository navigation
Conversation
With baseUrl set, tsc also resolves bare imports like 'src/App' from the project root, which Vite can't resolve, so typecheck passes but the build fails. baseUrl is also deprecated in TypeScript 6 (TS5101) and removed in TypeScript 7 (TS5102). paths works on its own with a ./ prefix.
|
|
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.
Problem
The
@/alias inbolt-vite-react-ts/tsconfig.app.jsonuses"baseUrl": ".". That has two side effects:baseUrlalso makes tsc resolve bare imports from the project root. For example,import App from 'src/App.tsx'insrc/main.tsxpassesnpm run typecheck, butnpm run buildfails because Vite only knows the@alias. So typecheck can say the project is fine when the build is broken.baseUrlis deprecated in TypeScript 6 (error TS5101) and removed in TypeScript 7 (error TS5102, plusTS5090for the non-relativesrc/*path). The template pinstypescript ^5.5.3today, but anyone who bumps TypeScript gets a typecheck error from the tsconfig itself.Solution
Drop
baseUrland make the path relative:"@/*": ["./src/*"].pathsdoesn't needbaseUrlsince TS 4.1, and this matches the existingresolve.aliasinvite.config.ts.Testing
In
bolt-vite-react-ts, afternpm ci:npm run typecheck,npm run lint,npm run build, andtsc --noEmit -p tsconfig.node.jsonall pass.Appvia@/App.tsxstill typechecks and builds.src/App.tsxnow fails typecheck with TS2307 (before: typecheck passed, build failed).tsc --noEmit -p tsconfig.app.jsonwith TypeScript 5.6.3, 6.0.3 and 7.0.2: passes on all three with this change; on main, 6.0.3 fails with TS5101 and 7.0.2 fails with TS5102/TS5090.npm run format:checkpasses.I didn't run the WebContainer browser tests locally.