Hey, I have the following snippet:
import React from 'react'
function Component() {
return (
<select hidden readOnly multiple value={["a", "c"]} name="letters">
<option value="a" />
<option value="b" />
<option value="c" />
</select>
)
}
but TS tells me that readOnly prop doesn't exist on select. If I remove it, React gives me a warning that I have a controlled select with no onChange nor readOnly and that I should add one of them. My use case is having a custom multi select component to style it better, but keep a hidden, read only select in DOM in order for <form> to work as expected (to have the field in the payload). Does anybody know how to make TS happy in this case? I expect the issue is in DOM types? I don't want to @ts-expect-error just yet...
Type '{ children: Element[]; hidden: true; multiple: true; name: string | undefined; value: string[]; readOnly: true; }' is not assignable to type 'DetailedHTMLProps<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>'.
Property 'readOnly' does not exist on type 'DetailedHTMLProps<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>'.ts(2322)
typescript@5.5.4