Skip to content

@react-aria/useTextField with TypeScript: Types of property 'value' are incompatible #3805

Closed
@cperilla318

Description

@cperilla318

🐛 Bug Report

When using useTextField, the types in @react-aria/texfield@3.21.0 don't match with the React types for the "value" prop on elements:

"Argument of type '{ ref?: LegacyRef<HTMLInputElement>; key?: Key; accept?: string; alt?: string; autoComplete?: string; autoFocus?: boolean; capture?: boolean | \"user\" | \"environment\"; ... 281 more ...; onTransitionEndCapture?: TransitionEventHandler<...>; }' is not assignable to parameter of type 'AriaTextFieldOptions<\"input\">'.
Types of property 'value' are incompatible.
Type 'string | number | readonly string[]' is not assignable to type 'string'. 
Type 'number' is not assignable to type 'string'.",

🤔 Expected Behavior

no type error

😯 Current Behavior

Type error
image

💁 Possible Solution

🔦 Context

Use the docs example

💻 Code Sample

https://codesandbox.io/s/patient-sky-5k8qky?file=/src/Input.tsx

🌍 Your Environment

Software Version(s)
@react-aria/textfield 3.21.0
Browser
Operating System

🧢 Your Company/Team

🕷 Tracking Issue (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions