Search keywords
no-unsafe-assignment useAutocomplete
Latest version
Steps to reproduce
Steps:
- Just open the live example with eslint activated: https://codesandbox.io/p/sandbox/fast-dew-mgthpm?from-embed
Current behavior
When doint the workaround for #39833, the eslint rule "@typescript-eslint/no-unsafe-assignment" is triggered because the key is of type "any". Using the "any" type is bad practice. Espacially, when there is a correct type for that usecase available: React.Key
...
const { key, ...optionProps } = getOptionProps({ option, index }); // Unsafe object destructuring of a property with an `any`
return (
<li key={key} {...optionProps}> // Unsafe assignment of an `any` value.
...
useAutocomplete.d.ts:
getOptionProps: (renderedOption: UseAutocompleteRenderedOption<Value>) => React.HTMLAttributes<HTMLLIElement> & {
key: any;
};
UPDATE: The same is true for the renderOption function Prop
renderOption?: (props: React.HTMLAttributes<HTMLLIElement> & {
key: any;
}, option: Value, state: AutocompleteRenderOptionState, ownerState: AutocompleteOwnerState<Value, Multiple, DisableClearable, FreeSolo, ChipComponent>) => React.ReactNode;
Expected behavior
Keys shold be of type "React.Key" not "any".
Search keywords
no-unsafe-assignment useAutocomplete
Latest version
Steps to reproduce
Steps:
Current behavior
When doint the workaround for #39833, the eslint rule "@typescript-eslint/no-unsafe-assignment" is triggered because the key is of type "any". Using the "any" type is bad practice. Espacially, when there is a correct type for that usecase available: React.Key
useAutocomplete.d.ts:
UPDATE: The same is true for the renderOption function Prop
Expected behavior
Keys shold be of type "React.Key" not "any".