Skip to content

Commit

Permalink
fix: enable autocomplete to use const type
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Sallai committed Mar 1, 2021
1 parent 5bd4cce commit d830a6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export interface UseAutocompleteProps<
/**
* Array of options.
*/
options: T[];
options: ReadonlyArray<T>;
/**
* If `true`, the input's text is selected on focus.
* It helps the user clear the selected value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ function Component() {
onChange(event, value: Person[]) {},
});

// options accepts const and value has correct type
useAutocomplete({
options: ['1', '2', '3'] as const,
onChange(event, value) {
expectType<'1' | '2' | '3' | null, typeof value>(value);
},
});

// Disable clearable

useAutocomplete({
Expand Down

0 comments on commit d830a6f

Please sign in to comment.