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

refactor: Add default event target types for HTML attribute interfaces #4606

Merged
merged 4 commits into from
Dec 15, 2024

Conversation

rschristian
Copy link
Member

Neither React nor Solid (if I've understood their types right, had to go looking for that and it's seemingly not in their org? weird) do this so I'm a tad apprehensive as otherwise seems like a pretty obvious DX improvement. Take the following example:

import type { JSX } from 'preact';

// Before
interface MyInputProps extends JSX.InputHTMLAttributes<HTMLInputElement> { ... }

// After
interface MyInputProps extends JSX.InputHTMLAttributes { ... }
interface MyWhackyInputProps extends JSX.InputHTMLAttributes<HTMLButtonElement> { ... }

Users can still supply the generic parameter if they wish but 99% of the time they're going to want the element associated with the attributes which we can simply assume as the default.

@coveralls
Copy link

coveralls commented Dec 12, 2024

Coverage Status

coverage: 99.615%. remained the same
when pulling 779f4a2 on refactor/default-element-targets
into 2beb9f7 on main.

@rschristian rschristian changed the title refactor: Assume default targets for HTML attribute interfaces refactor: Add default event target types for HTML attribute interfaces Dec 12, 2024
Copy link
Member

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a no-brainer honestly, great DX win, just the tests and we are good

src/jsx.d.ts Show resolved Hide resolved
@rschristian rschristian merged commit 2b82799 into main Dec 15, 2024
5 checks passed
@rschristian rschristian deleted the refactor/default-element-targets branch December 15, 2024 17:37
@JoviDeCroock JoviDeCroock mentioned this pull request Dec 18, 2024
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