-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
10.0.0-rc.3 preact/compat typescript incompatibilities #1930
Comments
The namespacing of Regarding the incorrect |
There's still no type safety for event handling in Preact till this day? |
Wow, jumped into the same issue and realized its a bug on preact |
Hey I might be missing something here but the typings for Should I open a PR for this or is somebody already on it? |
@alextompkins - For instance, this (fairly silly) example works:
...whereas with Side note: See #2706, those event types may be moving out of the JSX namespace. |
First off, well done on this excellent library. It boggles my mind how smaller this is from react.
I have some existing react libraries and a react app which I am trying out with preact. It is working fine but I had to do some modifications to the typescript typings as below:
I added the following definitions to compat/src/index.d.ts :
I also changed jsx to a global namespace in src/jsx.d.ts:
I also noticed that there are some subtle types missing, like e.g. the target in the onChange event for an input tag is not typed. I had this jsx line in which the event's target attribute was correctly inferred to be an html input element from the react typings:
that I had to change to the following as the preact event handlers all use the same event definition with target being untyped:
Are these by design or is there a reason I am not aware of for these missing types? I can go through the react typings and copy over some stuff to improve type checking, if you think this is of benefit to preact. These would be typescript typing updates only, requiring no changes in preact but improving greatly both switching to preact from react and fix subtle type checking errors like the event above.
The text was updated successfully, but these errors were encountered: