Issue on ctx object when updating to 26.3.1 #3185
Youssefbenmlih
started this conversation in
General
Replies: 1 comment
|
Hello, @Youssefbenmlih I can't figure out the cause from your samples, but, taking into account the given type of Consider the following pattern:
That approach is straightforward and has no conditional assignment. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
When i update to 26.3.1 my use of ctx.field does not work anymore.
my factory functions a bit like so :
and my middleware returns :
return { accessibleLeaveIds, ctx, request, response };But it seems that in the routing accessing accessibleLeaveIds through
ctx.accessibleLeaveIdsgenerates :the Property 'accessibleLeaveIds' does not exist on type '{ headers: IncomingHttpHeaders; } & { metrics: MetricManager; } & { request: Request<ParamsDictionary, any, any, ParsedQs, Record<...>>; response: Response<...>; }'.It seems to me that the issue is TypeScript's inability to narrow the union type from the factory method.
Everything works fine in 26.3.0 ctx.accessibleLeaveIds is recognized and it's typing is correct.
All reactions