Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with @types/express version 4.17.21 #1617

Open
2 of 4 tasks
ericwooley opened this issue Apr 28, 2024 · 1 comment
Open
2 of 4 tasks

Problem with @types/express version 4.17.21 #1617

ericwooley opened this issue Apr 28, 2024 · 1 comment

Comments

@ericwooley
Copy link

I have a typescript error in my generated routes code.

Version: 4.0.35 works
Version: 4.17.21 has errors

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

Generated code should be error free.

Current Behavior

No overload matches this call.
  Overload 1 of 2, '(path: PathParams, ...handlers: RequestHandler[]): Router', gave the following error.
    Argument of type 'RequestHandler<core.ParamsDictionary, any, any, core.Query, Record<string, any>>' is not assignable to parameter of type 'RequestHandler'.
      Type 'RequestHandler<core.ParamsDictionary, any, any, core.Query, Record<string, any>>' provides no match for the signature '(req: Request, res: Response, next?: NextFunction | undefined): any'.
  Overload 2 of 2, '(path: PathParams, ...handlers: RequestHandlerParams[]): Router', gave the following error.
    Argument of type 'RequestHandler<core.ParamsDictionary, any, any, core.Query, Record<string, any>>' is not assignable to parameter of type 'RequestHandlerParams'.ts(2769)

on line 47, of the following generated code:

/* tslint:disable */
/* eslint-disable */
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
import { TsoaRoute, fetchMiddlewares, ExpressTemplateService } from '@tsoa/runtime';
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
import { UsersController } from './../../../src/users/user.controller';
import type { Request as ExRequest, Response as ExResponse, RequestHandler, Router } from 'express';



// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

const models: TsoaRoute.Models = {
   "User": {
       "dataType": "refObject",
       "properties": {
           "id": {"dataType":"double","required":true},
           "email": {"dataType":"string","required":true},
           "name": {"dataType":"string","required":true},
           "status": {"dataType":"union","subSchemas":[{"dataType":"enum","enums":["Happy"]},{"dataType":"enum","enums":["Sad"]}]},
           "phoneNumbers": {"dataType":"array","array":{"dataType":"string"},"required":true},
       },
       "additionalProperties": false,
   },
   // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
   "Pick_User.email-or-name-or-phoneNumbers_": {
       "dataType": "refAlias",
       "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"email":{"dataType":"string","required":true},"name":{"dataType":"string","required":true},"phoneNumbers":{"dataType":"array","array":{"dataType":"string"},"required":true}},"validators":{}},
   },
   // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
   "UserCreationParams": {
       "dataType": "refAlias",
       "type": {"ref":"Pick_User.email-or-name-or-phoneNumbers_","validators":{}},
   },
   // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
};
const templateService = new ExpressTemplateService(models, {"noImplicitAdditionalProperties":"throw-on-extras","bodyCoercion":true});

// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

export function RegisterRoutes(app: Router) {
   // ###########################################################################################################
   //  NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look
   //      Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/lukeautry/tsoa
   // ###########################################################################################################
       app.get('/users/:userId',
           ...(fetchMiddlewares<RequestHandler>(UsersController)),
           ...(fetchMiddlewares<RequestHandler>(UsersController.prototype.getUser)),

           async function UsersController_getUser(request: ExRequest, response: ExResponse, next: any) {
           const args: Record<string, TsoaRoute.ParameterSchema> = {
                   userId: {"in":"path","name":"userId","required":true,"dataType":"double"},
                   name: {"in":"query","name":"name","dataType":"string"},
           };

           // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

           let validatedArgs: any[] = [];
           try {
               validatedArgs = templateService.getValidatedArgs({ args, request, response });

               const controller = new UsersController();

             await templateService.apiHandler({
               methodName: 'getUser',
               controller,
               response,
               next,
               validatedArgs,
               successStatus: undefined,
             });
           } catch (err) {
               return next(err);
           }
       });
       // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
       app.post('/users',
           ...(fetchMiddlewares<RequestHandler>(UsersController)),
           ...(fetchMiddlewares<RequestHandler>(UsersController.prototype.createUser)),

           async function UsersController_createUser(request: ExRequest, response: ExResponse, next: any) {
           const args: Record<string, TsoaRoute.ParameterSchema> = {
                   requestBody: {"in":"body","name":"requestBody","required":true,"ref":"UserCreationParams"},
           };

           // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

           let validatedArgs: any[] = [];
           try {
               validatedArgs = templateService.getValidatedArgs({ args, request, response });

               const controller = new UsersController();

             await templateService.apiHandler({
               methodName: 'createUser',
               controller,
               response,
               next,
               validatedArgs,
               successStatus: 201,
             });
           } catch (err) {
               return next(err);
           }
       });
       // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

   // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa


   // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
}

// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa

Possible Solution

Downgrade to @types/express version 4.0.35

Steps to Reproduce

  1. Create a new project following the quickstart guide, using pnpm

Context (Environment)

Version of the library: 6.2.1
Version of NodeJS: 21.7.3

  • Confirm you were using yarn not npm: [ ] I am using pnpm :(

Detailed Description

None

Breaking change?

None

Copy link

Hello there ericwooley 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant