TS2707 [ERROR]: Generic type 'RouterContext<R, P, S>' requires between 1 and 3 type arguments #468
-
|
Upgrading from version so for example the following code does not compile anymore: I could not find any thing in the documentation about what changes with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
The change was mentioned as a breaking change in v10.0.0. The error is accurate, in that 1 to 3 generic parameters are required. The first generic parameter is the route, which is then used to infer the route parameters. When the middleware is expressed in line, TypeScript can infer the route from the export const indexHandler = async (ctx: RouterContext<"/" | "/index">) => {
//
}That should resolve your issue. |
Beta Was this translation helpful? Give feedback.
The change was mentioned as a breaking change in v10.0.0.
The error is accurate, in that 1 to 3 generic parameters are required. The first generic parameter is the route, which is then used to infer the route parameters. When the middleware is expressed in line, TypeScript can infer the route from the
.get(),.all()etc. methods. In your case though, you need to supply it, because it cannot be inferred:That should resolve your issue.