lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.32k stars 481 forks source link

Routes.ts TSC Error expressAuthenticationRecasted #1624

Closed samuelexferri closed 3 weeks ago

samuelexferri commented 2 months ago

Sorting

Expected Behavior

TSC Ok

Current Behavior

I get this error:

src/routes/routes.ts:29:39 - error TS2352: Conversion of type '(expressRequest: Request, securityName: string, scopes: string[]) => Promise<void>' to type '(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, securityName: string, scopes?: string[] | undefined, res?: Response<...> | undefined) => Promise<...>' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
  Types of parameters 'expressRequest' and 'req' are incompatible.
    Type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>' is missing the following properties from type 'Request': cache, credentials, destination, integrity, and 13 more.

29 const expressAuthenticationRecasted = expressAuthentication as (req: ExRequest, securityName: string, scopes?: string[], res?: ExResponse) => Promise<any>;

Found 1 error in src/routes/routes.ts:29

Possible Solution

Adding an unknown convertion probably fix:

const expressAuthenticationRecasted = expressAuthentication as (req: ExRequest, securityName: string, scopes?: string[], res?: ExResponse) => Promise<any>;
const expressAuthenticationRecasted = expressAuthentication as unknown as (req: ExRequest, securityName: string, scopes?: string[], res?: ExResponse) => Promise<any>;

Steps to Reproduce

Empty

Context (Environment)

Version of the library: v6.2.1 Version of NodeJS: 20

Detailed Description

Breaking change?

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days