Skip to content
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

Possible bug when accepting class method suggestion(s) during autocompletion #472

Open
stefanos82 opened this issue Sep 1, 2024 · 11 comments

Comments

@stefanos82
Copy link

I have exported an interface that each method return a Promise with needed types accordingly.

When I implement them in a class, and I decide to start them manually with the keyword async, whichever method it suggests me, it prepends it with async too, thus leading to two keywords named async; if I don't use the aforementioned keyword, it just auto-completes whichever method I decide to choose without the async being added automatically for me.

Is this an expected behavior?

@stefanos82
Copy link
Author

OK, seems like this behavior has to do with how suggestion mechanism works with interfaces; it behaves the same when you extend an interface and attempt to re-use existing declarations from parent to child.

First you start typing declare and as soon as you get auto-completion suggestions and you choose the one that matches your need, by pressing tab, it prefixes it with yet another declare keyword.

@fannheyward
Copy link
Member

Can you reproduce the issue in VSCode? Sounds like the tsserver returns error suggestion.

@stefanos82
Copy link
Author

Well, I have tested it with VSCodium, not vscode, and it works as expected;

these are the vscodium specs:

Version: 1.92.2
Release: 24228
Commit: 21b1e2955ddda36eeba3a94e643128e465285b93
Date: 2024-08-15T18:27:27.910Z
Electron: 30.1.2
ElectronBuildId: undefined
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Linux x64 6.10.6-amd64

@fannheyward
Copy link
Member

Can't reproduce the declare issue. Please provide steps or code to reproduce it.

@stefanos82
Copy link
Author

stefanos82 commented Sep 12, 2024

  • Create a file where you declare your interface(s) in it; use Promise<> as your return type for each class method.
  • Then create another file where you start implementing a class that will use the interface.
  • On typing, you will get suggestions of course; start typing async and then the name of the class methods with Promise as their return type; press tab and you will trigger it.

I forgot to mention, the declare issue happens when you extend an interface and you start overriding a method from a parent; that's where declare gets duplicated when you repeat the aforementioned process.

@fannheyward
Copy link
Member

Still can't reproduce the duplicate async issue, can you init a test repo that broken with this issue?

@stefanos82
Copy link
Author

Let me try to reproduce it in a limited demo.

@stefanos82
Copy link
Author

I cannot reproduce it in a demo...the classes I'm working on come from sequelize package; could it be this case that triggers it, a problem somewhere in the package?

@stefanos82
Copy link
Author

output-2024-09-12_12.34.27.mp4

@fannheyward
Copy link
Member

Try minimal vimrc, only coc.nvim and coc-tsserver. From your screenshot, after you input async, declare products?... has been inserted, but later the line became async async destroy, why? I didn't see you do deleting actions.

@stefanos82
Copy link
Author

I just shared the problematic behavior with you that takes place in insert mode.

The line became async async destroy because I pressed u to undo changes and lead to the duplicated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants