Typescript: Auto imports not working with project references

Created on 17 Jul 2020  路  8Comments  路  Source: microsoft/TypeScript

TS Template added by @mjbvz

TypeScript Version: 4.0.0-dev.20200727

Search Terms

  • angular
  • project references
  • auto imports




  • VSCode Version: 1.47.2
  • OS Version: Mac OS Catalina 10.15.5

Steps to Reproduce:

I have an Angular project, and just 1 of the files don't have a proper suggestion support in it.
Same happens when I create a file via plus sign from the side bar.
VSCode doesn't suggest "obvious(necessary)" things, quite the contrary happens:
it suggests everything else what's available, but not what I need and not what really exists in the project.

Also, when I try to import environment object with 'src/environments/environment',
it doesn't seem to know about src folder(project_name/src).
Although it already works this way for all the other files in the project.

Cache cleaning && insiders build didn't help out, no errors in debug console and I couldn't find any useful tsserver logs.
Although I can send if necessary.
Having 3.9.7 TS


Does this issue occur when all extensions are disabled?: Yes

Needs Investigation

Most helpful comment

Confirm. Autocomplete not working via references in tsconfig.json

demo: https://github.com/zerkalica/ts-references-autoimport-bug/tree/autoimport-no-ref

Currently autocomplete works only with includes (cpu eating on big projects) and via "types" in package.json.

Autocomplete doesn't works with direct imports (without types in package.json)

All 8 comments

For me it's not a problem even for a session with screen sharing, if anything

Can you share the project that causes this?

Yup!
Working on it

@mjbvz here you go

https://github.com/EKashpersky/mentare-102740-0
https://github.com/EKashpersky/mentare-102740-1

Each project has // environment line their src/app/app.component.ts, and when I uncomment the line and do command + space to have suggestions list pop up, for 102740-0 I get nothing or allowedNodeEnvironmentFlags function from 'process' package, if npm -i has been ran.

Works fine for 102740-1.

Looks like src/environments/environment.ts and app.component.ts are part of separate tsconfig projects, although both of these project are both referenced by tsconfig.json.

Moving upstream to get the TypeScript team's feedback on this behavior

Confirm this issue. My composite projects referenced to each other don't auto import names from other connected projects

Confirm. Autocomplete not working via references in tsconfig.json

demo: https://github.com/zerkalica/ts-references-autoimport-bug/tree/autoimport-no-ref

Currently autocomplete works only with includes (cpu eating on big projects) and via "types" in package.json.

Autocomplete doesn't works with direct imports (without types in package.json)

Project reference imports like using @ namespace only works when there is already an import using that path. Otherwise it defaults to relative paths. Very annoying to have to manually type it out initially everytime

Was this page helpful?
0 / 5 - 0 ratings

Related issues

disshishkov picture disshishkov  路  224Comments

blakeembrey picture blakeembrey  路  171Comments

chanon picture chanon  路  138Comments

quantuminformation picture quantuminformation  路  273Comments

xealot picture xealot  路  150Comments