sajad torkamani

Create a .d.ts file somewhere (e.g., src/types/express.d.ts) and make sure this is included in the typeRoots setting in your tsconfig.json.

Example typeRoots value in tsconfig.json:

 "typeRoots": [
    "./node_modules/@types",
    "./src/domain/types"
 ],

Then extend the Express.Request interface in your .d.ts file:

declare global {
  namespace Express {
    interface Request {
      user: User
      foo: Foo
    }
  }
}

Leave a comment

Your email address will not be published. Required fields are marked *