-
-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typescript: typing for withIronSession handler is wrong #368
Comments
I think the whole typescript typing on export type Handler<Req, Res> = (
req: Req & { session: Session },
res: Res,
) => any;
export function withIronSession(
handler: Handler,
sessionOptions: SessionOptions,
): (...args: any[]) => Promise<any>; The implementation is correct though: https://github.com/vvo/next-iron-session/blob/master/lib/index.js#L98-L107 |
Hey there @akomm thanks for jumping in, the TypeScript situation of next-iron-session has been tricky since the beginning mostly I guess because of the way it is written (modify req object). If you have any ideas on how to improve this situation then you can either:
Thanks and good luck! |
Hello, Currently, I've solved it in the following way: and when you use p.s I tried a few other options (e.g function overloading) and didn't manage to solve the issue. |
@ApacheEx that solution worked for me and solved my problem. Thanks for sharing! |
For people to copy paste |
Hey there, the typings were fully redone as part of the V6. Changelog here: https://github.com/vvo/iron-session/releases/tag/v6.0.0 |
It should be a lot better now |
withSession
's handler is typed to get request as first argument, but when usinggetServerSideProps
the first argument iscontext
withreq
property. The example ssr-profile ignores the typing and destructures the context, for (type-wise) undefined property req.The text was updated successfully, but these errors were encountered: