Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing namespace of express in typescript

I wanna change the express namespace in my typescript file and add another option to it, but eslint get some errors,

declare global {
  namespace Express {
    interface Request {
      currentUser?: User;
    }
  }
}

Error is: ES2015 module syntax is preferred over namespaces.

how can i fix this error except change ts rules

like image 506
Mehrad Farahnak Avatar asked Oct 27 '25 13:10

Mehrad Farahnak


1 Answers

You can do it like this:

declare module 'express' {
  export interface Request {
    currentUser?: User;
  }
}
like image 112
Artur Minin Avatar answered Oct 30 '25 04:10

Artur Minin