iron-session
iron-session copied to clipboard
req.session.user is throwing ts error
Hello! First of all the library really amazing.
Second I am using Next with Prisma and whenever I try to assign user
to req.session
I get this error
Property 'user' does not exist on type 'IronSession'.ts(2339)
So I opened index.d.ts where session type is defined and had to change its type from this
interface IncomingMessage { session: IronSession; }
to this
interface IncomingMessage { session: any; }
And it worked! But if there is any other solution can you provide it please and thank you so much.
This is how you can define custom properties: https://github.com/vvo/iron-session/blob/a6c767d425c52575f743e86b64b8b4a4ce64add6/examples/next.js-typescript/lib/session.ts#L13-L18