I don't know how to correct the linting error. Perhaps I just don't fully understand the issue, but it doesn't seem to matter what I do. I just can't seem to get rid of the error. I'd rather not disable the rule unless the issue is that my linting rules are just too strict.
I'm using this in a fetch
with google geocode api.
fetch(uri)
.then(res => (res.json() as Promise<google.maps.GeocoderResponse>))
.then(data => {
const result = data.results[0].geometry;
// Unsafe assignment of an `any` value.
// Unsafe member access .results on an `any` value.
})
Any help would be appreciated.
CodePudding user response:
Have you tried specifying the type of data
?
.then((data: <DEFINE TYPE HERE>) => {
const result = data.results[0].geometry;
})
CodePudding user response:
try this it will work
(data as google.maps.GeocoderResponse).results[0].geometry
else define custom type in typescript for geocoderresponse and use it. url