In an application using an older version of oak, the middleware get's plugged into the handler as follows:
router.get("/path", isAdmin, getHandler)
Where isAdmin is something like:
export const isAdmin = async (ctx: RouterContext<"/path">, next: Function) => {
await next();
}
This no longer compiles. On further investigation I discovered it seems the middleware should now be typed as RouterMiddleware
But when I updated isAdmin to use RouterMiddleware like this:
export const isAdmin = async (ctx: RouterMiddleware<"/path">, next: Function) => {
await next();
}
It now fails to compile with the following error:
Argument of type '(ctx: RouterMiddleware</path>, next: Function) => Promise<void>' is not assignable to parameter of type 'RouterMiddleware<"/path", Record<string | number, string | undefined>, Record<string, any>>'.
Any ideas on how to fix this?