Skip to content

Typescript error when defining optionText on InputGuesser #640

@rvanlaak

Description

@rvanlaak

API Platform version(s) affected: 4.2.2

Description

Typescript error when defining optionText on InputGuesser. Via the SelectArrayInputProps and ChoicesProps the InputGuesser has access to the optionText prop. Functionally it works in modifying the value that's used on the select's options, and a callable also is supported:

How to reproduce

In React Admin define resource with relationship. In the edit form of the resource use the following fields:

    <InputGuesser source="company" optionText="name" />
    <InputGuesser source="user" optionText={(record) => `${record.firstName} ${record.lastName}`} />

Possible Solution

Relates to Typescript being able to resolve down towards all props. Somewhere the traversal gets broken.

Workaround

    {/* @ts-ignore */}
    <InputGuesser source="company" optionText="name" />

Additional Context

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