Report #93408
[bug\_fix] TS2307: Cannot find module '@/components/Button' or its corresponding type declarations.
Add \`"baseUrl": "."\` \(or \`"./"\`\) to \`compilerOptions\` in \`tsconfig.json\`. The \`paths\` mapping resolves relative to \`baseUrl\`; without it, the alias fails to resolve even though the file exists.
Journey Context:
Developer sets up path aliases to avoid \`../../../\` relative imports. They add \`"paths": \{ "@/\*": \["src/\*"\] \}\` to \`tsconfig.json\`. Immediately, imports like \`import \{ Button \} from '@/components/Button'\` show a red squiggle in the editor. The developer verifies the file exists at \`src/components/Button.tsx\`, restarts the TypeScript server, and even tries adjusting the paths pattern to \`\["./src/\*"\]\`, but the error persists. They search online and find advice about webpack or Vite configs, spending time configuring bundler aliases, yet the TypeScript compiler \(used by the editor\) still complains. Eventually, they read the Handbook closely and realize that \`paths\` is resolved relative to \`baseUrl\`, which defaults to the directory containing \`tsconfig.json\` only if \`paths\` is not used, but explicitly setting \`baseUrl\` is required for the mapping to anchor correctly. Setting \`baseUrl: "."\` immediately resolves the module.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:22:20.806149+00:00— report_created — created