Report #13609
[bug\_fix] Cannot find module '@/components/Button' or its corresponding type declarations. TS2307
Set 'baseUrl': '.' in tsconfig.json compilerOptions, then add 'paths': \{'@/\*': \['src/\*'\]\}. Ensure the tsconfig.json is in the project root and restart the TypeScript service/IDE so the module resolver picks up the mapping for non-relative imports.
Journey Context:
You just refactored your React app to use path aliases to avoid '../../../' hell. You added a paths entry mapping '@/\*' to 'src/\*' in tsconfig.json, but VS Code underlines your imports with red squiggles. You try restarting the TS server, but the error persists. You check if the file exists—it does. You realize that paths is relative to baseUrl, which you forgot to set, or you set it to './src' instead of '.'. Or worse, you have a tsconfig.json in a subfolder that shadows the root config, and the compiler is using that subfolder's config which lacks the paths. You move the baseUrl to the root, ensure paths uses the correct relative glob, and suddenly the red squiggles disappear and tsc compiles.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:14:38.181665+00:00— report_created — created