-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Wrong dedupe on auto-import completions #19417
Comments
Here's the completion entry we get back when trying to import one of two classes named
And here's the entry itself:
The
|
Thanks, hope it will be fixed for TS 2.6 final and October VS Code release, because it makes the feature unusable for now as it generates wrong code (when you are far in a file, you won't even see the import is bad). |
@andy-ms / @mhegazy What are your thoughts on how this should be fixed? Return multiple completion items, one for each unique symbol? Or have one completion that returns multiple Having a completion item for each of these symbols could be better UX in my option. The multiple code action approach would require that VSCode show some UI after you accept an completion so that you can then pick the correct import |
@mjbvz I think we can provide multiple |
Ok. To support that with the TSServer API, I'm thinking we'd need to add a interface CompletionEntry {
name: string;
source?: string;
...
} And then extend interface CompletionDetailsRequestArgs extends FileLocationRequestArgs {
entryNames: (string | { name: string, source?: string})[];
} Any better idea for this? |
You're right, we should provide the |
That sounds good to me. We'll just treat the |
I've tested in the last VS Code Insiders, and there is now a new problem : multiple imports are suggested when relevant, but the paths are now the bad ones : only deep imports are available. For example, instead of : import { EventEmitter } from '@angular/core'; It's now : import { EventEmitter } from '@angular/core/src/event_emitter'; It was handled fine when just one auto-import was suggested. Also, there was the same issue with the Import quick fix (#15223), but which was resolved a long time ago. |
@cyrilletuzi mind filing a new issue to track that. |
Ok, in TypeScript or VS Code repo ? |
TypeScript. |
TypeScript Version: 2.6.0-dev.20171019 and 2.7.0-dev.20171021
Tested in VS Code Insiders.
Following #7849 and microsoft/vscode#2635
Code
Install an Angular project :
Then in
src/app/app.component.ts
, add a new property and instantiate it withEventEmitter
, using the new auto-import on completion :Expected behavior:
Should be able to select the good class between the multiple ones available to have the good import :
Actual behavior:
Problem is : several librairies export a class
EventEmitter
with the same name.Currently, completion suggestions seem to be deduped, so just one is proposed, resulting in the wrong auto import :
By the way, in case of multiple tokens with the same name, the completion list should display an information about the packages concerned, to be able to choose the good one.
The text was updated successfully, but these errors were encountered: