-
Notifications
You must be signed in to change notification settings - Fork 12k
Type definitions not exported correctly for vscode (intellisense not working on clean projects) #16879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@AndrewKushnir you'll fix this or I put up a PR? I'm not getting it since you assigned it to someone else |
I don’t thinking adding I think this needs some digging to determine the course of action needed. |
@alan-agius4 is right, according to the TypeScript handbook:
Based on my understanding of TypeScript language service, I think it is able to do automatic import only if it already knows that the symbol is available somewhere in the current program. That said, I don't see any major downsides adding |
I did a quick check to see how many dependency gets added to the program by including |
I think the downside would be that the more packages add to the “global” state the slower the IDE would be because every time the TS server gets initialised, TS will need to resolve and scan all the definitions found specified in the typeRoots. At least from what I understand on how this works. @kyliau correct me if I am wrong 😁 Edit: Installing |
Yes, adding Like @alan-agius4 mentioned, there's also the question of how many packages should be added to the |
If you add node_modules/@angular you still not getting auto import for httpclient module (and other stuff I suppose), so that is a fix to be done somehow for sure. Plus you can always write that down in the angular doc and not adding it by default in the tsconfig |
@kyliau And I'm wondering, after the first manual import, the overhead of picking up all the packages isn't the same as adding it initially in the typeroots? |
Manual import would not pick up all the packages. It'd only pick up declaration files in the package that was imported. In the case of
Compare that to adding |
This seems more like a feature request for TypeScript and/or vscode (or maybe even the angular language service). I think to do this properly, it would need to be done at runtime and walk the node dependency graph of the project looking for entrypoints. Otherwise it will quickly become out of date, partially functional, and inconsistent between dependencies. This is also editor specific, whereas the TS config files are primarily build time configurations. These additions have the potential to cause longer and higher memory usage builds. |
I honestly don't know, I wish the editors' world at least wasn't so damn nasty. Watching Vue, for example, they made intellisense work through a vscode extension https://github.com/vuejs/vetur but it's quite strange that for angular I couldn't find even one of them working. |
I think I'm running into the same issue with a MaterialModule I'm making, which just imports all the |
Hey, also getting this. Any ideas how to resolve this? Currently using a fresh 9.1.9 project with vscode. |
Hi,
According to Typescript:
So removing this line resolved the imports problems. |
typescript is working on fixing the auto-import issue that's described in this ticket ;) |
ANy solution? same issue |
this not working for me, please explain.. |
Closing as this should is fixed in TypeScript 4.0 which is supported in now supported in version |
yes classes and components generated by cli or manually are suggested. Router, ActivatedRoute, FormsModule and ReactiveFormsModule working with auto import and suggest intellisense something interesante: HttpClientModule and HttpClient are located in @angular/common/http <<----subfolder http inside common folder Router, ActivatedRoute, FormsModule and ReactiveFormsModule are located in @angular/router @angular/forms <<-- not subfolder... Tested with 10.1.0-RC.0 |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I tried searching everywhere for this issue but actually very few people noticed it (to my surprise).
The only thing I could find is this stackoverlow question
🐞 bug report
Affected Package
The issue is caused by package @angular/....Is this a regression?
I don't think so, as far as I can recall IntelliSense on vscode never worked but it's a very subtle issue (for this reason I'm not sure when this started or if it has always been like this).
In fact, just a few people noticed this behavior because vscode seems to be smart enough to remember and understand after the first manual import
Description
Vscode has two ways to provide hints through IntelliSense to the developer (you can read it here):
It can either look for the node_modules/@types folder or get the type definition file in the package.json, under the "typings" or "types" key (the first way is more suited for non ts libraries/frameworks).
You enforce the first one through your cli when calling
ng new my-app
in tsconfig.json we find:but in all the new angular projects generated by the cli, the @types folder is missing the angular types:
Relating this behavior to how React handles this, for example, isn't ok. With React we correctly get suggestions and the type definitions file appear correctly in the @types folder:
So, knowing that maybe pointing typeRoots to the node_modules/@angular folder would solve the problem, an attempt I've done is to include it there.
Problem solved partially, why? Because then all the routing stuff were importable, but still not the http stuff.
How come?
Because vscode is looking at your package.json files available in the node_modules/@angular folder, with the
router
, everything's ok:but not with the
common
package.json:since the common.d.ts file has no reference for many stuff like, for example, the httpclient module:
🔬 Minimal Reproduction
See yourself, open stackblitz with a blank project: https://stackblitz.com/fork/angular
and write HttpC (press ctrl+space too that is usually the command to make the hints show up) and see that no correct suggestion is shown.
Anything else relevant?
I will put up a PR exporting all the needed definitions directly from the common.d.ts file and please, edit your cli to generate the tsconfig.json including node_modules/@angular
🌍 Your Environment
Angular Version:
The text was updated successfully, but these errors were encountered: