[useAutocomplete] Improve typeof groupOptions
in useAutocomplete
#40739
Labels
component: autocomplete
This is the name of the generic UI component, not the React module!
enhancement
This is not a bug, nor a new feature
package: base-ui
Specific to @mui/base
typescript
What's the problem?
Currently, the following type is true regardless of the inputs passed in to
useAutocomplete
:Essentially, the developer has to narrow or cast the type despite MUI being able to assert the correct type definition with the inputs of the
useAutocomplete
hook. I propose addressing the type definition hereWhat are the requirements?
groupBy
is passedtypeof groupedOptions = AutocompleteGroupedOption<T>[]
groupBy
is omitted,typeof groupedOptions = T[]
What are our options?
Proposed solution
We could do something like
useAutocomplete.d.ts
Effective implementation (abbreviated)
Resources and benchmarks
This was pointed out by @spencermehta
Minimal working playground link
Search keywords:
The text was updated successfully, but these errors were encountered: