Skip to content

How to extend Express Request? #47741

@george-norris-salesforce

Description

Why is Typescript NOT extending the Request object? I'm beyond frustrated trying to get this to work..

Declare the type.. after installing the @types/Express package..

// global.d.ts

declare namespace Express {
  interface Request {
    user: string;
  }
}
(req, res) => {
  const user = req.user
}

Property 'user' does not exist on type 'Request'

WHY? WHY? WHY?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions