Skip to content

[docs][autocomplete] Confusing TypeScript inference section #3853

@ZeeshanTamboli

Description

@ZeeshanTamboli

Docs feedback

How can we improve Base UI documentation?

The documentation at
https://base-ui.com/react/components/autocomplete#typescript-inference
currently states:

If using itemToStringValue, the value prop on the <Autocomplete.Item> must match the type of an item in the items array.

This wording is potentially misleading. The value prop on <Autocomplete.Item> must always match the item type from the items array passed to <Autocomplete.Root>, regardless of whether itemToStringValue is used.

In other words, itemToStringValue does not change the expected type of value., it only affects how items are displayed and matched. TypeScript already enforces this constraint even when itemToStringValue is not provided, as can be seen in the Autocomplete hero demo, which does not use itemToStringValue but still passes items of the same type to value.

Because this rule is unconditional, the sentence above appears unnecessary and may imply that the constraint only applies when itemToStringValue is used. Removing it (or rephrasing it as a general clarification) would make the TypeScript inference section more accurate and less confusing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: autocompleteChanges related to the autocomplete component.docsImprovements or additions to the documentation.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions