Skip to content

[Textfield] TS2322 with slotProps inputLabel #44633

Open
@sampain

Description

Steps to reproduce

Steps:

  1. Using Textfield with shrink to true
<TextField
  slotProps={{
    inputLabel: { shrink: true },
  }}
/>
  1. Build with TypeScript (with strict)

Returns

error TS2322: Type '{ shrink: true; } | { shrink: true; } | { id?: string | undefined; role?: AriaRole | undefined; form?: string | undefined; property?: string | undefined; key?: Key | null | undefined; ... 265 more ...; shrink: true; } | ... 7 more ... | { ...; }' is not assignable to type 'SlotProps<ElementType<InputLabelProps, keyof IntrinsicElements>, {}, BaseTextFieldProps> | undefined'.
  Object literal may only specify known properties, and 'shrink' does not exist in type '(Partial<Omit<DetailedHTMLProps<LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement>, "ref"> & { ...; }> & SlotCommonProps) | ... 5 more ... | (Partial<...> & SlotCommonProps)'.'.  

Current behavior

Error on build

Expected behavior

Suppose to build like
<TextField InputLabelProps={{ shrink: true }} />

Doc still suggest to use it this way even if InputLabelProps is deprecated: https://mui.com/material-ui/react-text-field/#shrink

Context

No response

Your environment

No response

Search keywords: TS2322 inputLabel slotProps Textfield

Metadata

Assignees

Labels

component: text fieldThis is the name of the generic UI component, not the React module!typescript

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions