You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have defined an application state type and a separate request state type. If I use the Context type like this Context<RequestContext, AppContext> everything looks good within my handler. But my issue starts when I try to use this handler in a router I get a typescript error that looks like this.
The types of 'app.state' are incompatible between these types.
Type 'Record<string, any>' is not assignable to type 'AppContext'.deno-ts(2345)
I have been looking through the code trying to figure out where this Record<string, any> is coming from and from digging around I can see that RouteContext is not specifying the second generic to Context
export interface RouterContext<
R extends string,
P extends RouteParams<R> = RouteParams<R>,
// deno-lint-ignore no-explicit-any
S extends State = Record<string, any>,
> extends Context<S>
I think this should be something like
export interface RouterContext<
R extends string,
P extends RouteParams<R> = RouteParams<R>,
// deno-lint-ignore no-explicit-any
S extends State = Record<string, any>,
AS extends State = Record<string, any>
> extends Context<S, AS>
to fix this issue. I'm not a Typescript expert though so happy to be pointed to the right direction if I'm incorrect in my assumption here. Happy to attempt to make the PR as well if this is a valid solution.
The text was updated successfully, but these errors were encountered:
Hello,
I have defined an application state type and a separate request state type. If I use the Context type like this
Context<RequestContext, AppContext>
everything looks good within my handler. But my issue starts when I try to use this handler in a router I get a typescript error that looks like this.I have been looking through the code trying to figure out where this
Record<string, any>
is coming from and from digging around I can see thatRouteContext
is not specifying the second generic toContext
I think this should be something like
to fix this issue. I'm not a Typescript expert though so happy to be pointed to the right direction if I'm incorrect in my assumption here. Happy to attempt to make the PR as well if this is a valid solution.
The text was updated successfully, but these errors were encountered: