I presume the TypeScript engine within Visual Studio Code has received an update that is now complaining for the first time that my pre-existing custom props on HTML element
React type definition file (by default - index.d.ts
when staring with create-react-app
) contain list of all the standard HTML elements, as well as known attributes.
In order to allow custom HTML attributes, you need to define it's typing.
Do that by expanding HTMLAttributes
interface:
declare module 'react' {
interface HTMLAttributes extends AriaAttributes, DOMAttributes {
// extends React's HTMLAttributes
custom?: string;
}
}