Problem Statement
Explain module resolution and when to use path mapping.
Explanation
Module resolution decides how an import path maps to a file. In Node-style resolution, TS looks for exact files, then index files, then `node_modules`. Use path mapping to replace long `../../..` with friendly aliases and to swap mocks in tests. Keep aliases aligned with your bundler (Vite/Webpack) and your runtime (Node or browser).
Code Solution
SolutionRead Only
// tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": { "@app/*": ["src/*"], "@tests/*": ["tests/*"] }
}
}
// Import now: import { foo } from '@app/utils/foo';