tsconfig paths and module resolution errors in VS Code
See original GitHub issueBug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
@angular/cli: 1.4.9 node: 7.9.0 os: darwin x64 @angular/animations: 4.4.5 @angular/common: 4.4.5 @angular/compiler: 4.4.5 @angular/core: 4.4.5 @angular/forms: 4.4.5 @angular/http: 4.4.5 @angular/platform-browser: 4.4.5 @angular/platform-browser-dynamic: 4.4.5 @angular/router: 4.4.5 @angular/cli: 1.4.9 @angular/compiler-cli: 4.4.5 typescript: 2.3.4
macOS Sierra 10.12.6 VS Code 1.17.2
Repro steps.
My tsconfig path property seems broken. When I replace my path mapped imports (@shared, @assets etc.) with the equivalent coded relative paths, typescript module resolution seems to work (vs code intellisense is happy) I have a large angular 2 project and am used to aliasing my asset and shared directories this way. NOTE: project builds and (seems) to run just fine This has been reported often, but I can’t make sense of the current state of this issue. This more than annoying as VS Code reports Angular spurious errors on all of my components. I also suspect this is why I get the infamous Can’t read property isSkipSelf of null when I open my templates (html) in VS Code. I was running 1.4.2 and just tried ~1.4.2, which resolves to 1.4.9 in my package.json, to no avail. Will 1.5.x fix this? How can I help debug this without providing a copy of my app?
Thanks in advance. Regards.
The log given by the failure.
Desired functionality.
Mention any other details that might be useful.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:41
- Comments:42 (5 by maintainers)
Top Related StackOverflow Question
@mehs2690 can you type
environmentin editor ( don’t add import statement yet ) and then pressCtrl + .when cursor in environment to see what option vscode suggest? Remember that because tsconfig.json and tsconfig.json has different baseUrl so you have to align path config accordinglyhere is my config: tsconfig.json
tsconfig.app.json
I had the same issue but it seams it was resolved with using a more “explicit” relative path in
baseUrlintsconfig.tswith"./src"Before:
After: