Skip to content
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

[Typescript] Fix props not spreadable to input elements #3764

Merged
merged 2 commits into from
Oct 15, 2022

Conversation

mwszekely
Copy link
Contributor

This is meant to be an extremely minor fix for the following problem I've run into in the most recent version of Preact:

// Props are spreadable to all types except for input elements
const a = <div {...({} as h.JSX.HTMLAttributes<HTMLDivElement>)} />;            // Works fine
const b = <input {...({} as h.JSX.HTMLAttributes<HTMLInputElement>)} />;        // TS Error

The only change was updating its definition from

input: HTMLAttributes<HTMLInputElement> & { defaultValue?: string };

to

input: HTMLAttributes<HTMLInputElement> & { defaultValue?: string | SignalLike<string> };

I will admit I'm not sure if there's a deeper issue that was causing the problem or if this has unintended consequences elsewhere, but just adjusting this one single type seemed to solve everything that I had noticed personally.

src/jsx.d.ts Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Oct 13, 2022

Coverage Status

Coverage remained the same at 99.53% when pulling b99d217 on mwszekely:master into 43204de on preactjs:master.

@marvinhagemeister marvinhagemeister merged commit 7b7ac5f into preactjs:master Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants