hookstate icon indicating copy to clipboard operation
hookstate copied to clipboard

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

Open nateshmbhat opened this issue 3 years ago • 4 comments

Here is the image that shows the issue :

image

nateshmbhat avatar Sep 02 '22 11:09 nateshmbhat

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

avkonst avatar Sep 04 '22 05:09 avkonst

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?

nateshmbhat avatar Sep 04 '22 05:09 nateshmbhat

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

avkonst avatar Sep 04 '22 05:09 avkonst

This is this issue I believe https://github.com/microsoft/TypeScript/issues/26892. I reproduced it outside of hookstate with just 2 overloads for a function.

avkonst avatar Sep 09 '22 07:09 avkonst