Typescript auto-imports use full path instead of barrels

I have a rather substantial Angular project and for a very long time when I typed something like `@Component` and allowed it to auto-import I would get the correct import:

import { Component } from '@angular/core';

But then there was an update and now the same thing results in this import:

import { Component } from '@angular/core/src/metadata/directives';

Which the TypeScript compiler does not like. This change has dramatically impacted my development speed as I have to update the import every time and when I do something with a Component, Input, Output, Inject, or more they each get their own line that I have to correct.

Note that my webpack.config.js file will not import because it requires a target flag (production, dev, staging...). This has always been the case, so I don't think it is related, but maybe a recent change requires this?

I have tried invalidating my caches and deleting my node_modules folder with no success. 



Comment actions Permalink

What IDE version do you use? Can you recreate the issue when using a new Angular cli project? Also, do you have any symlinks in your project path?

Comment actions Permalink

I am currently using the most up to date WebStorm, the about says this:

Version: 1.37.1
Commit: f06011ac164ae4dc8e753a3fe7f9549844d15e35
Date: 2019-08-15T16:17:25.463Z
Electron: 4.2.7
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 5.0.0-23-generic
I do not use symlinks in my project path.
I created a new Angular CLI project, and the problem did not persist. I tried a few things to replicate, but my project is old and large. It is a hybrid AngularJS/Angular app as a result the configuration of Angular is necessarily complex. We are working to get to a pure Angular app, but we are not there yet. While this seems to indicate that the problem is with my configuration, are there things I could look into to solve it? 

I have confirmed that the "Use directory import when index.js is available" is checked and it works with non-angular code.
Comment actions Permalink

No ideas unfortunately... With default setting for imports it should just work


Please sign in to leave a comment.