Skip to content

Conversation

@gugu
Copy link

@gugu gugu commented Feb 7, 2020

No description provided.

@coveralls
Copy link

coveralls commented Feb 7, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 87c9e49 on Short-io:master into 4bbe421 on express-validator:master.

Copy link
Member

@fedeci fedeci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't default to any when no type is specified because ValidationChain would not override it.

// this is the result we get
(req: any, res: any, next: any): void

The only solution is the one suggested, but I'm not 100% satisfied with that.
/cc @gustavohenke

import { ContextBuilder } from '../context-builder';

export function check(
export function check<Req = any, Res = any, NextFn = any>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function check<Req = any, Res = any, NextFn = any>(
export function check<Req = Request, Res = any, NextFn = (error?: any => void)>(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would even go one step further and make it Req extends Request instead

const protectedNames = ['errorMessage', 'in'];

export function checkSchema(schema: Schema, defaultLocations: Location[] = validLocations) {
export function checkSchema<Req = any, Res = any, NextFn = any>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function checkSchema<Req = any, Res = any, NextFn = any>(
export function checkSchema<Req = Request, Res = any, NextFn = (error?: any => void)>(

@gustavohenke gustavohenke force-pushed the master branch 2 times, most recently from 3177f64 to 6e160b1 Compare April 7, 2023 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants