Closed wayneashleyberry closed 6 years ago
I'm also having trouble getting validate.js to working in a Typescript environment. I don't think the Typescript bindings are right for this library. I can't get the compiler to recognise these as properties even thought they're mentioned in the documentation:
I've also raised an open question on Stack Overflow: http://stackoverflow.com/questions/43928659/resolving-various-typescript-type-declaration-issues
I've added this code to my project and validate.validators
is no longer not found.
// validate.d.ts
import { ValidateJS } from 'validate.js';
declare module 'validate.js' {
interface ValidateJS {
validators: any;
}
}
It would be great if typescript definition supported entire library functionality.
The validate.d.ts
is good, but it seams that npm version lacks proper typings. In the same file from npm you can see that there is only
export declare interface ValidateJS {
(attributes: any, constraints: any, options?: any): any;
async(attributes: any, constraints: any, options?: any): Promise<any>;
single(value: any, constraints: any, options?: any): any;
}
declare var validate: ValidateJS;
export default validate;
@ansman can you please update npm version to match git one?
I found a typo in the declarations: https://github.com/ansman/validate.js/blob/master/validate.d.ts#L9
It should be wrapErrors
not WrapErrors
I was in the middle of writing an updated declaration file before realizing you already have one here (doh!) so I can merge my work into this one.
Does this issue still exist in 0.12.0?
@ansman it looks fine in 0.12.0. Thanks 👍
I'm not sure if this is an issue with TypeScript itself, or the definitions for validate.js.
I've put together an example repo at https://github.com/wayneashleyberry/validate-types/
The following sample code fails a typescript check.