I am not sure why typescript is barking at me when I try to use my own created type from express' types.
Argument of type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is not assignable to parameter of type 'Context'.
Property 'req' is missing in type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' but required in type 'Context'.
The type signatures are identical, i'm not really sure what I'm doing wrong here.
How can I pass req and res to getStatus?
Routes.ts
import getStatus from "../routes/status";
export default function routes({ app }: Context): void {
app.get("/_status", ({ req, res }: Context) => getStatus(req, res));
} // barking at me here ^^^^^^^^
Status.ts
import { Context } from "../../utils/Context";
import express from "express";
export default async function getStatus({req}: Context, { res }: Context): Promise<Express.Response> {
//....
}
Context.ts
import { Request, Response, Application } from "express";
export type Context = {
req: Request;
res: Response;
app: Application;
};