I’m just starting to learn jsdoc, so this is all new to me.
In exrpress-session we have a session object, which stores session data req.session
. I’d like to store a userId
in the session object. But when doing req.session.userId
my IDE yells at me because userId
does not exist on Session & Partial<SessionData>
(which of course it does not, because I have never defined it anywhere).
- As far as I understand Partial makes all attributes optional. I may not want this. Is it possible to ‘unpartial’ something?
- How can I define the SessionData object with the userId?
- What does
Type1 & Type2
do exactly? I assume it combines the two types somehow?
Note: I’m only using js, so only jsdoc. No .ts or .d.ts files for me.
Edit:
I want to define my custom SessionData so that jsdoc doesn’t give me red error squiggles.
app.get('/something', (req, res, next) => {
let uid = req.session.userId;
});
how can I tell jsdoc that .userId is part of my custom session object?
2