Open henribru opened 3 years ago
I was thinking we could have something similar to what React does https://github.com/vuejs/vue-next/pull/3370
Would love this. I have had to write a utility to narrow the event types at the moment but would prefer to avoid the additional boilerplate.
I assume it's not as simple as e.g. replacing
Event
withInputEvent
foronInput
or it would probably have been done already
Would like an explanation why they are typed as such. They are only used for JSX so I don't think it would actually break anything.
@pikax kindly asking what's blocking #3370? If that PR could not be landed in the near future, could we at least have these types corrected (e.g. onInput: InputEvent
) first?
What problem does this feature solve?
Currently the JSX types specify that native input event handlers receive an
Event
: https://github.com/vuejs/vue-next/blob/8ed3ed6c27b0fb9a1b6994eddc967e42d4b3d4e1/packages/runtime-dom/types/jsx.d.ts#L1210This is very general compared to the runtime type. As an example,
@input
on an input element will actually give you anInputEvent
. It would be useful if the correct event type could be inferred so that we don't have to cast the event object. I assume it's not as simple as e.g. replacingEvent
withInputEvent
foronInput
or it would probably have been done already, but is this something that could potentially be solved?What does the proposed API look like?
N/A, just a type improvement, not an API