Tsed: AuthenticatedMiddleware cannot use route Decorators

Created on 22 May 2018  路  1Comment  路  Source: tsedio/tsed

Informations

Type |聽Version
---|---
Bug | 4.x


Description

My custom AuthenticatedMiddleware makes use of the "@HeaderParams()" decorator. But my Typescript compiler seems to have an issue with it.

src/modules/auth/MyAuthenticatedMiddleware.ts(6,22): error TS2415: Class 'MyAuthenticatedMiddleware' incorrectly extends base class 'AuthenticatedMiddleware'.
  Types of property 'use' are incompatible.
    Type '(endpoint: any, request: any, next: any, userTokenHeader: any) => Promise<any>' is not assignable to type '(endpoint: EndpointMetadata, request: Request, next: NextFunction) => void'.

Acceptance criterias

  • [x] Example (log, usecase, etc...)
  • [x] Ts.ED version (bug/question)
question

Most helpful comment

Hi @Kapulara,

This is the problem if you inherit your class from the original class. You need to keep the same signature. So the solution is to not inherit your class from the AuthenticatedMiddleware.

Just look the original implementation of the AuthenticatedMiddleware ;). But I think, isn't a problem.

See you,
Romain

>All comments

Hi @Kapulara,

This is the problem if you inherit your class from the original class. You need to keep the same signature. So the solution is to not inherit your class from the AuthenticatedMiddleware.

Just look the original implementation of the AuthenticatedMiddleware ;). But I think, isn't a problem.

See you,
Romain

Was this page helpful?
0 / 5 - 0 ratings