I have a set of controller functions for my REST API and I\'m getting lots of the following
error TS7006: Parameter \'req\' implicitly has an \'any\' type.
Rather than installing types(@types/express
) you should also define request parameters. Since every parameter is string, interface should base on dictionary.
Here is an inline route handler:
interface GetParams {
[key: string]: string
paramName: string
}
router.get('/:paramName', (req, res) => {
res.send('Parameter is ' + req.params.paramName)
})