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

TS2339:Property 'checkBody' does not exist on type 'Request'. #363

Closed
veerandev opened this issue Jun 30, 2017 · 5 comments
Closed

TS2339:Property 'checkBody' does not exist on type 'Request'. #363

veerandev opened this issue Jun 30, 2017 · 5 comments

Comments

@veerandev
Copy link

Using v3.2.0 in typescript, getting TS2339:Property 'checkBody' does not exist on type 'Request'.
As of v3.1.0, the type definitions are shipped with the library. What else could cause this issue?

public add(req: express.Request, res: express.Response, next: express.NextFunction) {
    ...
     if(req.checkBody('name', 'Invalid name').isValidInput()){
       
        ...
     }

@veerandev
Copy link
Author

public add(req: any, res: express.Response, next: express.NextFunction) {
...
if(req.checkBody('name', 'Invalid name').isValidInput()){

    ...
 }

@gustavohenke
Copy link
Member

Have you uninstalled old typings from DefinitelyTyped? If you have both you're likely to get conflicts.

@gustavohenke
Copy link
Member

Also, try v3.2.1, as it ships with lots of typings improvements.

@chrstntdd
Copy link

chrstntdd commented Aug 2, 2017

EDIT:

This solution solved all my problems

I'm having this same issue. I uninstalled @types/express-validator and don't have any other type definitions in my project, but keep getting errors about many of the validator properties not existing on the Request type. I'm running version 3.2.1 on a Mac, if that helps any.

I applied the middleware in my main Api.ts file with all my other middleware, so the types should be available throughout my program, right? I get the intellisense and autocompletion when I begin typing req. but when I try to run my mocha tests, which are also .ts files, that's when I'm getting the typescript compilation errors.

@lock
Copy link

lock bot commented Jun 2, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants