I try to use aliases for my project.
After starting the app the paths
object gets removed and no alias is working.
This is my current simple tsconfig.json
:
{
"compilerOptions": {
"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",
"baseUrl": "src",
"paths": {
"@styles/*": ["styles/*"],
"@components/*": ["components/*"]
}
},
"include": [
"src"
]
}
After starting it looks like this:
{
"compilerOptions": {
"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",
"baseUrl": "src"
},
"include": [
"src"
]
}
My console shows this error message:
I also tried to move the paths to tsconfig.paths.json
and extend the tsconfig.json
.
// tsconfig.json
{
"extends": "./tsconfig.paths.json",
"compilerOptions": {
...
"baseUrl": "src"
}
}
// tsconfig.paths.json
{
"compilerOptions": {
"paths": {
"@styles/*": ["./styles/*"],
"@components/*": ["./components/*"]
}
}
}
My third attemnt was to use craco
which also doesn't worked out.
UPDATE
restarting VSC and the server did the trick for me.
I get it to work with craco.