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

"Add explicit type" refactoring #865

Open
mikavilpas opened this issue Apr 16, 2023 · 1 comment
Open

"Add explicit type" refactoring #865

mikavilpas opened this issue Apr 16, 2023 · 1 comment
Labels
🙅 Require better TypeChecker This refactoring would need Abracadabra to determine types faster and better than it can do ✨ Feature New refactoring or feature

Comments

@mikavilpas
Copy link

Is this request related to a problem? Please describe.

In short, this is to go from const foo = {...} to const foo: Thinginator<Thing | string> = {...}.

Pretty often I find myself seeing what type is inferred for my variables. The type inference usually works great, but here are some use cases where I like to type out the explicit type:

  • for clarity, an explicit type can help the reader understand better or more quickly
  • sometimes the type inference is misleading or it could be written in a clearer way

For functions it's already possible to add the return type with another refactoring.

Describe the solution you'd like

I would like to have a refactoring for this, such as "Add explicit type" or "Add type"

Additional context

Currently I do this by hovering the variable name with my mouse in order to bring up this popup (can also do it with with ⌘K ⌘I), and then selecting the contents with the mouse to copy them with ⌘C 😄

Here's a picture:

image

To be clear, here's what I would like to see after applying a refactoring for this:

image

@mikavilpas mikavilpas added the ✨ Feature New refactoring or feature label Apr 16, 2023
@didaquis
Copy link

didaquis commented Apr 3, 2024

That would be very useful

@nicoespeon nicoespeon added the 🙅 Require better TypeChecker This refactoring would need Abracadabra to determine types faster and better than it can do label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 Require better TypeChecker This refactoring would need Abracadabra to determine types faster and better than it can do ✨ Feature New refactoring or feature
Projects
None yet
Development

No branches or pull requests

3 participants