I am relatively new to Node+Typescript, I have a file which import another file module using like this import { IS_PRODUCTION } from '@/config/config';, I cant understand how it is imported by @ symbol.
Need some help in understanding this.
Thanks
[EDIT]: this is tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true,
"target": "es2018",
"noImplicitAny": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"sourceMap": true,
"outDir": "build",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@@/*": ["./*"]
},
"module": "commonjs",
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["build", "node_modules"]
}
Your tsconfig.json has some custom paths setup. One of them is this:
"@/*": ["./src/*"],
That means that when typescript sees a path that starts with @/whatever then it translates that to path/of/tsconfig/here/src/whatever.
It's nice because it allows you load files with paths from the root of the project. That way if you move a file you don't have to change all the imports.
You can read about this feature in the documentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With