I'm running an express.js application using TypeScript. Every time I try to process request.query.foo I get the following error:
Argument of type 'string | ParsedQs | string[] | ParsedQs[] | undefined' is not assignable to parameter of type 'string'.
Setup:
import { Request, Response } from 'express';
function bar(request: Request, response: Response) {
const foo: string = request.query.foo; //marked as error
}
I read on the documentation of Express that you can set a configuration called "query parser" that when set to "simple" will always parse the query parameters as a string
The problem is that Typescript still thinks that something other than string or undefined may come and I can't seem to find a way to override the Request interface, I can only extend it.
Is there any way to override the Request interface? is there something wrong in my approach?

npm install @types/express