A couple of projects we're working on contain React components that allow any available HTML attribute to be passed to them. We use React.HTMLProps to extend the component-specific props for this.
import React from 'react';
interface Props extends React.HTMLProps<HTMLDivElement> {}
export default class Example extends React.Component<Props> {
render() {
const { ...props } = this.props;
return <div {...props}/>;
}
}
The types for a few props (like contentEditable) have been changed in #40658 (released as version 16.9.4) which breaks this with the following error:
TS2322: Type '{ accept?: string | undefined; acceptCharset?: string | undefined; action?: string | undefined; allowFullScreen?: boolean | undefined; allowTransparency?: boolean | undefined; alt?: string | undefined; ... 354 more ...; key?: string | ... 1 more ... | undefined; }' is not assignable to type 'DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>'. Type '{ accept?: string | undefined; acceptCharset?: string | undefined; action?: string | undefined; allowFullScreen?: boolean | undefined; allowTransparency?: boolean | undefined; alt?: string | undefined; ... 354 more ...; key?: string | ... 1 more ... | undefined; }' is not assignable to type 'HTMLAttributes<HTMLDivElement>'. Types of property 'contentEditable' are incompatible. Type 'boolean | "true" | "false" | "inherit" | undefined' is not assignable to type 'boolean | undefined'.
The changes in #40658 resulted in the contentEditable prop having a type of 'boolean | "true" | "false" | "inherit" | undefined' while the HTMLDivElement > HTMLElement > ElementContentEditable has a type of 'boolean | undefined'
@types/reactpackage and had problems.Definitions by:inindex.d.ts) so they can respond.A couple of projects we're working on contain React components that allow any available HTML attribute to be passed to them. We use
React.HTMLPropsto extend the component-specific props for this.The types for a few props (like
contentEditable) have been changed in #40658 (released as version16.9.4) which breaks this with the following error:The changes in #40658 resulted in the
contentEditableprop having a type of'boolean | "true" | "false" | "inherit" | undefined'while theHTMLDivElement > HTMLElement > ElementContentEditablehas a type of'boolean | undefined'