Closed sm3sher closed 1 week ago
I'll look into this issue
@sm3sher (@balajis-qb @martijnrusschen )
Target is not necessarily HTMLInput, as onChangeRaw is also fired on Day Component selection and click events.
For a typesafe implementation, why not use instanceof HTMLInputElement
to determine event.target before accessing event.target.value?
You are indeed correct.
So far I've been filtering out the Day Component selection and click events by checking if (e.target.value !== undefined)
to ensure I am working with an HTMLInputElement
.
I will give it a try with instanceof
check.
Update: Working with instanceof HTMLInputElement
does the job for me.
I conclude from this that onChangeRaw
is currently more precisely typed than it was in @types/react-datepicker
?
@sm3sher @balajis-qb ( cc. @martijnrusschen ) Are there any outstanding issues regarding this issue?
None that I know of. I am closing this issue.
Describe the bug After updating to the newest types included version (
7.0.0
)onChangeRaw
seems to be typed differently than before.In
@types/react-datepicker
it was typed like this:But in the latest version this has changed:
The problem here is that neither
React.MouseEvent
norReact.KeyboardEvent
provide thetarget
asHTMLInputElement
even though the target seems to be of typeHTMLInputElement
. This leads toevent.target.value
being invalid typescript.My current workaround is to access the value via
(event.target as HTMLInputElement).value
but I would hope for a better solution.To Reproduce
event.target.value
Expected behavior
onChangeRaw
should provide the correct types or at least none that are in conflict with@types/react-datepicker
.Desktop (please complete the following information):