Skip to content

fix(bolt-vite-react-ts): drop baseUrl from the @/ path alias - #138

Open
Mohith26 wants to merge 1 commit into
stackblitz:mainfrom
Mohith26:fix/vite-react-ts-paths-no-baseurl
Open

Mohith26 wants to merge 1 commit into
stackblitz:mainfrom
Mohith26:fix/vite-react-ts-paths-no-baseurl

Conversation

@Mohith26

@Mohith26 Mohith26 commented Nov 3, 2026

Copy link
Copy Markdown

Problem

The @/ alias in bolt-vite-react-ts/tsconfig.app.json uses "baseUrl": ".". That has two side effects:

  1. baseUrl also makes tsc resolve bare imports from the project root. For example, import App from 'src/App.tsx' in src/main.tsx passes npm run typecheck, but npm run build fails because Vite only knows the @ alias. So typecheck can say the project is fine when the build is broken.
  2. baseUrl is deprecated in TypeScript 6 (error TS5101) and removed in TypeScript 7 (error TS5102, plus TS5090 for the non-relative src/* path). The template pins typescript ^5.5.3 today, but anyone who bumps TypeScript gets a typecheck error from the tsconfig itself.

Solution

Drop baseUrl and make the path relative: "@/*": ["./src/*"]. paths doesn't need baseUrl since TS 4.1, and this matches the existing resolve.alias in vite.config.ts.

Testing

In bolt-vite-react-ts, after npm ci:

  • npm run typecheck, npm run lint, npm run build, and tsc --noEmit -p tsconfig.node.json all pass.
  • Importing App via @/App.tsx still typechecks and builds.
  • Importing via src/App.tsx now fails typecheck with TS2307 (before: typecheck passed, build failed).
  • tsc --noEmit -p tsconfig.app.json with 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.
  • Root npm run format:check passes.

I didn't run the WebContainer browser tests locally.

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.
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

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.

1 participant