Namespace 'Express' has no exported member 'SessionData'

It appears the SessionData interface was removed from the global Express namespace, at the former line 24 on October 13, and recently published in the corresponding DefinitelyTyped modules -

https://github.com/HoldYourWaffle/DefinitelyTyped/commit/0cec4865fe7fd873952fc6901553a96648a7c889#diff-c38f30a0fdd238f104a7392ff3881fa97d8b4497d75e9617163ac1b5fceb75bf

Lots of discussion here - https://github.com/DefinitelyTyped/DefinitelyTyped/pull/46576

I suspect this will be eventually be updated in the connect-mongo code at some point, but in the meantime you can work around it with the skipLibCheck flag mentioned by @benhu, or, if you want to leave that feature on for other libraries, you can add the interface back in within your own code somewhere with something like this:

// WORKAROUND TODO: Remove when the connect-mongo types are updated
declare global {
  namespace Express {
    interface SessionData {
      cookie: any
    }
  }
}

I reverted back to this version to fix the issue: "@types/express-session": "1.15.16",


For the connect-mongo lib type check, try to add skipLibCheck option to your tsconfig.json

{
  "compilerOptions": {
    ....
    "skipLibCheck": true
  }
}

For the inline code, try to add // @ts-ignore

// @ts-ignore
req.session.user = user;

Please note that it is just a workaround, I have encountered same issue today when I try to rebuild the docker image on the DockerHub without any code changed.