From 67f224630a06198b9ca127c2ec121dbdec964a1c Mon Sep 17 00:00:00 2001 From: Blake Embrey Date: Thu, 21 Apr 2016 17:29:55 -0700 Subject: [PATCH] TypeScript: Fix implicit any, fix `Promise` usage --- lib/ajv.d.ts | 14 +++++++++----- package.json | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/ajv.d.ts b/lib/ajv.d.ts index e2b638f..0434e11 100644 --- a/lib/ajv.d.ts +++ b/lib/ajv.d.ts @@ -9,10 +9,14 @@ declare namespace ajv { addMetaSchema(schema: Object, key?: string): void; validateSchema(schema: Object): boolean; getSchema(keyRef: string): ValidateFunction; - removeSchema(schemaKeyRef?: Object | string | RegExp); + removeSchema(schemaKeyRef?: Object | string | RegExp): void; addFormat(name: string, format: FormatValidator | FormatDefinition): void; addKeyword(keyword: string, definition: KeywordDefinition): void; - errorsText(errors?: Array, options?: ErrorsTextOptions); + errorsText(errors?: Array, options?: ErrorsTextOptions): string; + } + + interface Thenable { + then (onFulfilled?: (value: R) => U | Thenable, onRejected?: (error: any) => U | Thenable): Thenable; } interface ValidateFunction { @@ -21,7 +25,7 @@ declare namespace ajv { dataPath?: string, parentData?: Object | Array, parentDataProperty?: string | number - ): boolean | Promise; + ): boolean | Thenable; errors?: Array; } @@ -36,7 +40,7 @@ declare namespace ajv { formats?: Object; schemas?: Array | Object; missingRefs?: boolean | string; - loadSchema?: (uri: string, cb: (err, schema) => any) => any; + loadSchema?: (uri: string, cb: (err: Error, schema: Object) => any) => any; removeAdditional?: boolean | string; useDefaults?: boolean | string; coerceTypes?: boolean; @@ -84,7 +88,7 @@ declare namespace ajv { dataPath?: string, parentData?: Object | Array, parentDataProperty?: string | number - ): boolean | Promise; + ): boolean | Thenable; errors?: Array; } diff --git a/package.json b/package.json index 36ad7cb..9754dd3 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "test-fast": "AJV_FAST_TEST=true npm run test-spec", "test-debug": "mocha spec/*.spec.js --debug-brk -R spec", "test-cov": "istanbul cover -x '**/spec/**' node_modules/mocha/bin/_mocha -- spec/*.spec.js -R spec", - "test-ts": "tsc --target ES2015 lib/ajv.d.ts", + "test-ts": "tsc --target ES5 --noImplicitAny lib/ajv.d.ts", "bundle": "./scripts/bundle . Ajv pure_getters", "bundle-regenerator": "./scripts/bundle regenerator", "bundle-nodent": "./scripts/bundle nodent",