I want to simplify my import paths so that I can get rid of deeply nested paths. I'm using React with typescript so I edit my tsConfig file in this way,
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"*": ["src/*"]
},
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"]
}
The problem is when I try to import any file from src it says module not found.
import app from "App"
where App is a directory that contains index.ts
CodePudding user response:
try to add @/ before steric.
"paths": {
"@/*": ["src/*"]
},