Session: VSCode not loading merged declaration

Created on 11 Nov 2020  Â·  3Comments  Â·  Source: expressjs/session

After upgrading typescript and express-session, the tsc is loading custom type defination stubs.

enter image description here

I am getting this error even though i have merged type declaration here

enter image description here

Also i have added ./typing-stubs in tsconfig.json

"typeRoots": [
      "./typing-stubs",
      "./node_modules/@types"
],

The problem is, type merging for express is loading but not for express-session

enter image description here

Most helpful comment

Hopefully of some help. I've just sorted it here with:

declare module "express-session" {
  interface Session {
    user: string;
  }
}

The interface decalred for req.session seems to have changed from SessionData to Session from @types/express-session 1.17.0 → 1.17.1.

This issue is probably more at home over at https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/express-session where the @types/* modules live.

All 3 comments

Hopefully of some help. I've just sorted it here with:

declare module "express-session" {
  interface Session {
    user: string;
  }
}

The interface decalred for req.session seems to have changed from SessionData to Session from @types/express-session 1.17.0 → 1.17.1.

This issue is probably more at home over at https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/express-session where the @types/* modules live.

Thanks a lot @bencevans you saved my day

req.session seems to have changed from SessionData to Session

@bencevans Then why did clicking on session in req.session I was redirected to SessionData typing stub?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Jpunt picture Jpunt  Â·  17Comments

Matthew-Christopher picture Matthew-Christopher  Â·  27Comments

neutron92 picture neutron92  Â·  20Comments

G-Adams picture G-Adams  Â·  16Comments

gk0us picture gk0us  Â·  18Comments