As already explained to me in THIS question (thank you by the way), i can use TS configuration file to provide baseUrl
and paths
to be able to reduce nonsense paths like ../../../../someModule
to way shorter, aliased versions like @AliasPath/someModule
. So, I modified my tsconfig.app.json
(please note, I modified .app.json config file, not main tsconfig.json in root folder) file with following line:
....
"baseUrl": "./",
....
"paths": {
"@services/*" : ["app/services/*", "src/app/services/*"]
}
In code I try to import one service by:import { CommunicationService } from "@services/communication.service";
Project is building fine, but TypeScript is unable to recognize my defined path aliases, marking them with red squiggle line:
And reporting missing files in problem tab:
The question is, how can I instruct TypeScript (because I assume it's TypeScript issue) about my paths aliases?
This seems to be an issue with VS Code as you can see on the following link for example (it is one of many): VSCode ignores paths in tsconfig.app.json
But I have found a workaround for me, since I had the same problem. I just installed the extention TypeScript Importer. This solved it for me.
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