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

schema.ts Typescript compilation error - No overload matches this call #1034

Closed
timothyallan opened this issue May 8, 2021 · 13 comments · Fixed by #1035
Closed

schema.ts Typescript compilation error - No overload matches this call #1034

timothyallan opened this issue May 8, 2021 · 13 comments · Fixed by #1035

Comments

@timothyallan
Copy link

Hi there,
Just started getting Typescript build errors happening in the past few hours with 6.11.0, and also now with last 2 releases? I've been using 6.10.1 without issue since release. Tried downgrading to 6.10.1 and 6.10.0 and am still getting the same issue now? Did those versions get re-pushed, or is something else up?

I found the previously logged Typescript Issues with your npm 7 update, and already have my tsconfig file ignoring node_modules. It seems all the .ts source files are included in the release, whereas 6.9.2 changelog explicitly mentions that the .ts source files are removed?

Also did the obligatory node_modules delete and reinstall, same thing. Using npm 6.14.12 as I've found 7 to be a nightmare!

15 35.46 node_modules/express-validator/src/middlewares/schema.ts(72,15): error TS2769: No overload matches this call.
#15 35.46   Overload 1 of 2, '(predicate: (value: string, index: number, array: string[]) => value is keyof Validators<any> | keyof Sanitizers<any>, thisArg?: any): (keyof Validators<any> | keyof Sanitizers<...>)[]', gave the following error.
#15 35.46     Argument of type '(method: keyof ParamSchema) => method is keyof Validators<any> | keyof Sanitizers<any>' is not assignable to parameter of type '(value: string, index: number, array: string[]) => value is keyof Validators<any> | keyof Sanitizers<any>'.
#15 35.46       Types of parameters 'method' and 'value' are incompatible.
#15 35.46         Type 'string' is not assignable to type '"optional" | "in" | keyof Validators<any> | keyof Sanitizers<any> | "errorMessage"'.
#15 35.46   Overload 2 of 2, '(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[]', gave the following error.
#15 35.46     Argument of type '(method: keyof ParamSchema) => method is keyof Validators<any> | keyof Sanitizers<any>' is not assignable to parameter of type '(value: string, index: number, array: string[]) => unknown'.
#15 35.46       Types of parameters 'method' and 'value' are incompatible.
#15 35.46         Type 'string' is not assignable to type '"optional" | "in" | keyof Validators<any> | keyof Sanitizers<any> | "errorMessage"'.
------

To Reproduce

Compile/build/load a project.

Express-validator Version: 6.11.0
Typescript v 4.2.4

Screen Shot 2021-05-07 at 10 48 08 PM

@prosavage
Copy link

Just experienced this too

@fedeci
Copy link
Member

fedeci commented May 8, 2021

Seems to be similar to #973
@gustavohenke we should do something to avoid this issue again. Maybe a .npmignore may solve the problem 🤔

@timothyallan
Copy link
Author

For those who are in a pinch and can't compile their production apps, simply deleting all the .ts files inside node_modules/express-validator/src/ seems to work.

@prosavage
Copy link

prosavage commented May 8, 2021 via email

@fedeci
Copy link
Member

fedeci commented May 8, 2021

Also excluding node_modules/ from tsconfig.json should work.

@timothyallan
Copy link
Author

Nope, you’d think so, but apparently not. That’s why I mentioned it in the original issue, as it was a bit odd.

it was also mentioned in the other related issue too: #973 (comment)

@amanolar94
Copy link

For those who are in a pinch and can't compile their production apps, simply deleting all the .ts files inside node_modules/express-validator/src/ seems to work.

Do you mean all the .ts files in the folder and all subfolders?

@timothyallan
Copy link
Author

Yep.

@amanolar94
Copy link

It worked indeed... I used that line: sudo find . -name "*.ts" -type f -delete

@timothyallan
Copy link
Author

Yes, that's basically what I found as well. Just a disclaimer for that ^ above before anyone runs it all willy nilly: if you runs that in your /src folder, it'll delete -all- .ts files in your entire project ;)
I'd recommend doing something a bit more controlled, i.e. find ./node_modules/express-validator/src/ -name "*.ts" -type f -delete

@amanolar94
Copy link

Yes you are correct I forgot to mention that I redirected there... But this is better of course so no accidents would happen 😜

@gustavohenke
Copy link
Member

Thanks all! Fix is in v6.11.1.

@RinwaOwuogba
Copy link

In my case, the issue still persisted on the latest version of express-validator but I fixed it by updating my typescript version to a more recent one.
3.33.333 -> 4.2.3

My project uses TypeORM and running typeorm init seems to have installed a version of typescript that was causing these build issues with express-validator.

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

Successfully merging a pull request may close this issue.

6 participants