question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: [TS] No overload matches this call.

See original GitHub issue

Describe the bug

When using as middleware typescript complains about the ValidationChain not being assignable to a RequestHandler

const getCertificateValidation = [
  query('data')
    .not()
    .isEmpty()
    .trim()
    .isBase64()
    .customSanitizer((value) => JSON.parse(Buffer.from(value, 'base64').toString()))
    .isJSON(),
];
routes.get('/investors/certificate', getCertificateValidation, getCertificate);

Error in full:

No overload matches this call.
  Overload 1 of 3, '(path: PathParams, ...handlers: RequestHandler<null, any, null, SanitisedQueryData>[]): Router', gave the following error.
    Argument of type 'ValidationChain[]' is not assignable to parameter of type 'RequestHandler<null, any, null, SanitisedQueryData>'.
      Type 'ValidationChain[]' provides no match for the signature '(req: Request<null, any, null, SanitisedQueryData>, res: Response<any, number>, next: NextFunction): any'.
  Overload 2 of 3, '(path: PathParams, ...handlers: RequestHandlerParams<Record<string, any> | undefined, any, null, SanitisedQueryData>[]): Router', gave the following error.
    Argument of type '(req: Request<null, null, null, SanitisedQueryData>, res: Response) => Promise<void>' is not assignable to parameter of type 'RequestHandlerParams<Record<string, any> | undefined, any, null, SanitisedQueryData>'.
      Type '(req: Request<null, null, null, SanitisedQueryData>, res: Response) => Promise<void>' is not assignable to type 'RequestHandler<Record<string, any> | undefined, any, null, SanitisedQueryData>'.
        Types of parameters 'req' and 'req' are incompatible.
          Type 'Request<Record<string, any> | undefined, any, null, SanitisedQueryData>' is not assignable to type 'Request<null, null, null, SanitisedQueryData>'.
            Types of property 'params' are incompatible.
              Type 'Record<string, any> | undefined' is not assignable to type 'null'.
                Type 'undefined' is not assignable to type 'null'.

Express-validator version:

  • Version: 6.8.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
moshiecommented, Jan 4, 2021

Will do can’t say I’ll get to it today but sometime this week.

0reactions
fedecicommented, Jan 4, 2021

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

No overload matches this call. Type 'string' is not assignable to ...
This happens when you do not assign your types properly. Your variable data Type MUST match the passing data type ...
Read more >
No overload matches this call with styled components ...
No overload matches this call in TypeScript is really annoying and there aren't too many solutions around there, though we have a solution!...
Read more >
"No overload matches this call" typescript error when passing ...
The problem is that Stores is typed as "array needs to contain at least one entry", while stores is typed as "array with...
Read more >
No overload matches this call when trying to use array.reduce
I get the output I'm looking for, but typescript is yelling at me with this 700 line error message: No overload matches this...
Read more >
TS2769: No overload matches this call error when building ...
[tsl] ERROR in /home/node/app/resources/js/educational/components/ActionForm.vue.ts(4,3) TS2769: No overload matches this call. Overload 1 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found