Report #96608
[bug\_fix] Cannot find module '@/components/Button' or its corresponding type declarations. \(2307\)
Set 'baseUrl': '.' in compilerOptions, then define 'paths': \{ '@/\*': \['src/\*'\] \} \(adjust 'src/\*' to match your source directory relative to baseUrl\). Ensure 'include' covers the files using the alias. Restart the TS server/IDE.
Journey Context:
You configure a path alias like '@/' in your Vite or webpack config so imports like '@/utils/helper' work at runtime. Everything builds fine, but VS Code shows red squiggles with 'Cannot find module'. You try adding 'paths' to tsconfig.json with '@/\*': \['src/\*'\], but the error persists. You realize you forgot 'baseUrl': '.' which makes paths relative to the project root. You add it, still fails. You check the actual folder structure and realize your code is in './client/src' not './src', so the path mapping is wrong. After correcting to 'client/src/\*', it works. You learn that TypeScript's module resolution is independent of your bundler's resolution and must be explicitly configured.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:44:35.580793+00:00— report_created — created