I am using superagent
in a TypeScript project and have installed @types/superagent
but am seeing a type error I don't understand. Given the following...
const myRequest = request
.get('/path/to/api')
.end((err, res) => {
// Do stuff with err and res
})
I get these errors for err
and res
:
Parameter 'err' implicitly has an 'any' type.ts(7006)
Parameter 'res' implicitly has an 'any' type.ts(7006)
But at the same time TypeScript does seem to know the types of these variables because when I hover on them in VSCode it shows the correct types from @types/superagent
, as can be seen in the below image.
In the image it shows that it is correctly getting the type of res
as request.Response
from @types/superagent
.
Therefore I don't understand why I am getting these implicit type errors. Is anybody able to explain this to a TypeScript newbie? Thanks :)