You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistency in generic parameter inference #38264
Argument of type '{ value: string; }' is not assignable to parameter of type 'Partial<HTMLElement>'. Object literal may only specify known properties, and 'value' does not exist in type 'Partial<HTMLElement>'.
Related Issues: I'm pretty sure I didn't choose a decent title for the issue, so my ability to search for this is limited as well.
I can understand this could be viewed as feature request/improvement, but there are a couple of reasons that make the behaviour feel buggy:
The inference works correctly for the events call, which is resolved as events<HTMLInputElement>.
The intellisense works on the props argument, which means at some point, the compiler understands I'm writing a Partial<HTMLInputElement>. But for some reason, it resolves the call to props<HTMLElement>, so the code fails to typecheck. I can work around it by adding the type parameter, but it degrades de developing experience.
Testing this again, I noticed that, if props returns {}, the call is inferred as props<HTMLInputElement>({}), but adding the value (which shows up in autocomplete) transforms the call into props<HTMLElement>({ value: '42' }).
Activity
ilogico commentedon May 1, 2020
I have found a workaround, which is to declare props as:
ilogico commentedon Mar 25, 2021
Testing this again, I noticed that, if
propsreturns{}, the call is inferred asprops<HTMLInputElement>({}), but adding thevalue(which shows up in autocomplete) transforms the call intoprops<HTMLElement>({ value: '42' }).