schema.ts Typescript compilation error - No overload matches this call
See original GitHub issueHi 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
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (3 by maintainers)
Top GitHub Comments
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.Thanks all! Fix is in v6.11.1.