Skip to content

Do these types belong to HTMLAttributes? #4202

@iivvaannxx

Description

@iivvaannxx
  • Check if updating to the latest Preact version resolves the issue

Describe the bug
Looking at these type declarations, I can see some attributes inside the HTMLAttributes interface that are commented as 'Standard HTML Attributes' but many of them aren't standard at all.

In my particular case I spent a lot of time trying to setup a type with Typescript that used HTMLAttributes for a couple of elements (HTMLInputElement and HTMLTextAreaElement) which discriminated attributes from one or another depending on a prop value. I was expecting the rows attribute to be present only on the HTMLTextAreaElement and not in the HTMLInputElement because rows is a native element of a textarea and not of an input. I assumed this and slammed my head onto a wall when I figured out that the attribute rows wasn't being discriminated because it was present as a 'standard' element in the general HTMLAttributes interface.

Is it intended to be like this because something that I am missing? (I am not very familiar with preact). Every other major framework (including React, Astro and Svelte) don't include this 'standard' attribute.

image

To Reproduce

I don't think an actual minimal repo isn't necessary in this case, but I have this example of the Typescript Playground which tries to grab the 'rows' attribute from an input element using both the react typings and the preact ones. While the preact ones are resolved, the react ones are not (as I would expect).

Expected behavior

The 'rows' key of the HTMLAttributes<HTMLInputElement> should not be resolved (how it happens with the react types).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions