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

Bug : Not getting code completion (Types) for setting initial value for the state #336

Closed
nateshmbhat opened this issue Sep 2, 2022 · 4 comments
Labels
question Further information is requested

Comments

@nateshmbhat
Copy link

Here is the image that shows the issue :

image

@nateshmbhat nateshmbhat changed the title Not getting code completion (Types) for setting initial value for the state Bug : Not getting code completion (Types) for setting initial value for the state Sep 2, 2022
@avkonst
Copy link
Owner

avkonst commented Sep 4, 2022

hmm... you are right... Typescript stopped showing type suggestions... I think it is because it can not decide which overload it needs to choose until the value is provided. I have put a workaround for TS like this, would it be acceptable?
image

@nateshmbhat
Copy link
Author

This way seems unusual to me...
Probably will be confusing to others. Is there no way to have it auto detect based on the generic type we give to hookstate function?

@avkonst
Copy link
Owner

avkonst commented Sep 4, 2022

I am not sure. I need to ask Typescript team why VSCode is confused in this case.

@avkonst
Copy link
Owner

avkonst commented Sep 9, 2022

This is this issue I believe microsoft/TypeScript#26892. I reproduced it outside of hookstate with just 2 overloads for a function.

@avkonst avkonst added the question Further information is requested label Sep 9, 2022
@avkonst avkonst closed this as completed Dec 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants