Answer the question
In order to leave comments, you need to log in
How to use tsconfig path aliases?
Good afternoon, why are aliases not replaced on the way to modules during compilation?
tsconfig:
"moduleResolution": "node",
"baseUrl": "./src",
"paths": {
"@api/*": ["api/*"]
},
import routes from '@api/routes';
pjroot/src/api/routes.ts
Error: Cannot find module '@api/routes'
Answer the question
In order to leave comments, you need to log in
No, there is no out-of-the-box solution. And it won't. Why? Fuck you, that's why .
There are a bunch of third-party crutches, google it to your liking.
PS
Otherwise, why do we need aliases in ts at all?
paths
written down to reflect the behavior of fashion bundlers, such as webpack, and not vice versa. Those. it is supposed to be paths
used only when there is already a assembler that implements all the logic, and not as the primary configuration source.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question