I'm using typescript for the backend of my web-app and I have incorporated express-session. I have @types/express and @types/express-session but unfortunately I continuously get type errors stating:
Property 'session' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'
Does anyone have any idea what is happening?
Versions:
"express": "^4.17.1",
"express-session": "^1.17.1",
"@types/express": "^4.17.11",
"@types/express-session": "1.17.0",
example code:
const auth_data: authSuccess|authError = await discordClient.exchangeCodeForTokens(String(disCode));
if(!auth_data) {throw new Error('Could not Authorize!')}
req.session.oauth = auth_data;
The last line here would throw the type error: Property 'session' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'
The issue was I imported express session like this:
const session = require('express-session')
Instead of like this:
import session from 'express-session';
Which makes total sense. I don't know why I didn't think to look at my imports!