Search code examples
typescripttypescript-typingsexpress-session

Typescript not loading merged declaration


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


Solution

  • I just got the answer from the express team on the issue

    The interface declared for req.session is changed from SessionData to Session from @types/express-session 1.17.0 → 1.17.1. You can see here https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/express-session

    So the fix is

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