Property 'currentUser' does not exist on type 'Request<ParamsDictionary>'. 31 const user = req['currentUser']; code example

Example 1: Property 'userId' does not exist on type 'Session & Partial'.ts(2339)

//After updating express-session, it changes from sessionData to session.
//so you'll have to merge declarations


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

Example 2: Property 'isAuth' does not exist on type 'Request'

// create file custom.d.ts and declare the following

declare namespace Express {
  export interface Request {
      user: any;
  }
  export interface Response {
      user: any;
  }
}