Skip to content

Any plans to support @types/express@5 (Express 5)? #126

Description

@aleksandr-shevchenko-0

Hey! We've run into a type compatibility issue with Express 5.

Description

csrf-csrf type declarations are incompatible with projects using @types/express@5. This is because @types/express-serve-static-core@5.0.2+ removed the deprecated param(name: string, defaultValue?: any): string method from the Request interface (see DefinitelyTyped#71024), making the Request types from Express 4 and Express 5 structurally incompatible.

All versions up to 4.0.3 have @types/express@^4.17.21 in devDependencies, so the bundled .d.cts / .d.ts declarations are built against Express 4 types.

Environment

  • csrf-csrf: 4.0.3
  • @types/express: 5.0.6
  • @types/express-serve-static-core: 5.0.2+ (where param() was removed)
  • express: 5.2.1
  • TypeScript: 5.9.3

Errors

When consuming csrf-csrf in a project with @types/express@5:

error TS2345: Argument of type 'Request' (from @types/express@5)
is not assignable to parameter of type 'Request' (from @types/express@4).
  Property 'param' is missing in type 'Request' (@types/express-serve-static-core@5.0.7)
  but required in type 'Request' (@types/express-serve-static-core@4.17.43).

This affects doubleCsrfProtection, generateToken, and the getTokenFromRequest callback in config options.

Question

Are there any plans to update the type declarations to support @types/express@5 / Express 5? This is also related to #67.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions