preact icon indicating copy to clipboard operation
preact copied to clipboard

fix TargetedEvent target definition

Open oltdaniel opened this issue 1 year ago • 0 comments

Why this change?

The Typescript definitions for events are still painful to use, as there are many conflicts with existing UI libraries. For example, @mui/material is built around the .target property. The typescript definitions of preact will cause the developer a headache as the typescript definition for the ChangeEvent does not work with .target or .currentTarget without a few lines of Typscript pain around it.

Issues with this change

I needed to change the test case, as it uses currentTarget. Currently there is no "easy fix" to make both currentTarget and target work in the same manner, as there will be conflicts due to two possible types when reading the value, which typescript cannot handle.

Simply try to solve the type issues here: https://github.com/preactjs/preact/pull/3723/files#diff-4b06a366f0a931f1bcf0692b56074ecf2b561160741f28d958c9985007d28125R62

oltdaniel avatar Sep 13 '22 08:09 oltdaniel