Express-jwt middleware typescript types issue
user
is not an existing property on req
object. You can make your own typings for req
object by creating a .d.ts
file on your project, for example, create a express.d.ts
file and it will contains:
declare namespace Express { export interface Request { user: SomeType }}
Demo: https://repl.it/repls/OldlaceWhoppingComputationalscience
Try deleting the express.d.ts
and the error will appears again.
declare global { namespace Express { interface Request { user?: UserPayload; } }}
this is an example of UserPaylaod
interface UserPayload { id: string; email: string; }