Skip to content

style prop type error #269

@Haaxor1689

Description

@Haaxor1689

If I just try to pass text area attributes (from React.InputHTMLAttributes) to TextareaAutosize there is a type error that height property of style does not match.

type Props = React.InputHTMLAttributes<HTMLTextAreaElement>;
const Component: React.FC<Props> = props => <TextareaAutosize {...props} />;

Here is the full error:

Type '{ accept?: string | undefined; alt?: string | undefined; autoComplete?: string | undefined; autoFocus?: boolean | undefined; capture?: string | boolean | undefined; checked?: boolean | undefined; ... 279 more ...; css?: InterpolationWithTheme<...>; }' is not assignable to type 'Pick<TextareaAutosizeProps, "style" | "autoComplete" | "autoFocus" | "disabled" | "form" | "maxLength" | "minLength" | "name" | "placeholder" | "readOnly" | ... 262 more ... | "wrap">'.
  Types of property 'style' are incompatible.
    Type 'CSSProperties | undefined' is not assignable to type '(CSSProperties & Pick<CSSProperties, "height" | "width" | "translate" | "color" 
| "clipPath" | "filter" | "marker" | "mask" | "alignContent" | ... 753 more ... | "vectorEffect"> & { ...; }) | undefined'.
      Type 'CSSProperties' is not assignable to type 'CSSProperties & Pick<CSSProperties, "height" | "width" | "translate" | "color" | "clipPath" | "filter" | "marker" | "mask" | "alignContent" | ... 753 more ... | "vectorEffect"> & { ...; }'.
        Type 'CSSProperties' is not assignable to type '{ height?: number | undefined; }'.
          Types of property 'height' are incompatible.
            Type 'string | number | undefined' is not assignable to type 'number | undefined'.
              Type 'string' is not assignable to type 'number | undefined'.  TS2322

I don't feel like I should be getting an error there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions