node.js - Using express-validator typescript definitions -


I'm trying to convert some of my code into typecript, but problems with Express-Vedic definitions

My code looks like this:

  /// & lt; Reference path = '.. .. .. .. .. / d.ts / node.d.ts' / & gt; /// & lt; Reference path = '.. .. .. .. .. / d.ts / express.d.ts' / & gt; /// & lt; Reference path = '.. .. .. .. .. / d.ts / express-validator.d.ts' / & gt; Import Express = Expected ('Express'); Import Verifier = Required ('express-recognizer'); Validate the function (Re: Express Request, Re-Express. Response) {req.assert ('name', 'name is required'). NotEmpty (); Var errors = req.validationErrors (); If (errors! == empty & errors. Conviction & gt; 0) {res.json ({Result: incorrect, errors: errors}); return false; } Back true; }   

The typewriter compiler generates the following error:

  Error TS 2094: property does not exist at the value of 'expression' type 'express.Request' Error TS2094: property does not exist at the value of 'validation errors' type 'express.Request'   

which clearly sees the extrash-validated definition

 < code> Export Interface Request Validation {Check (Field: String, Message: String): Validator; Emphasis (region: string, message: string): verifier; Cleanliness (Area: String): Cleanliness; OnValidationError (func: (msg: string) => zero): zero; }   

The request is clear on my understanding of the desired interface. The request interface should be expanded, but modifying this interface does not really help.

Am I doing something wrong?

Thank you!

This is what I see: express accrediting library increases the express request . That is, it defines current request to existing methods in Express.

Disclaimer: I can not find any good documents for the express accredited library and if any link I can be more accurate.

With this in mind, if the Express Validate Library Exports extends the request interface, the definition should reflect this here is an example for which the definitions are spread .

  Announced module Express {Interface Request expressValidator.RequestValidation {}}   

This will solve problems with responsibility , - If someone finds some documents, then I hope that the validatonErrors problem can be solved in the same way.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -