TypeScript: `suggestions.data` is of type `any`
Aerophite opened this issue · 1 comments
Aerophite commented
Bug Report
Describe the Bug
When using the autocomplete in TypeScript, suggestions.data
is an array of type any
. I believe this to be because AutocompletePrediction
is any
since it doesn't exist in the index.d.ts
file.
How to Reproduce
import usePlacesAutocomplete from 'use-places-autocomplete';
export const AutocompleteLocation = (): JSX.Element => {
const {
suggestions: {
data,
},
setValue,
} = usePlacesAutocomplete({
requestOptions: {
componentRestrictions: { country: 'us' },
},
callbackName: 'loadPlaceAutocomplete',
debounce: 300,
});
/**
* The below will result in "Unsafe member access .description on an any value." since `data` is an array of `any`.
* Note that I am seeing this when using typescript-eslint.
*/
data.map((suggestion) => suggestion.description);
};
Expected Behavior
That suggestions.data
is properly typed instead of any
Screenshots
Your Environment
- Device: MacBook Pro (2017)
- OS: macOS Catalina version 10.15.7 (19H114)
- Browser: N/A
- Version: 1.7.0
Additional Information
Any other information about the problem here.
wellyshen commented
@Aerophite Thank you for the bug reporting, it should be fixed in the latest version.