Skip to content

Commit

Permalink
feat: types definitions (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
vankop authored and evilebottnawi committed Sep 26, 2019
1 parent ba01fe5 commit facb431
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
32 changes: 32 additions & 0 deletions index.d.ts
@@ -0,0 +1,32 @@
import {JSONSchema4, JSONSchema6, JSONSchema7} from 'json-schema';
import {ErrorObject} from 'ajv';

type Schema = JSONSchema4 | JSONSchema6 | JSONSchema7;
type PostFormatter = (formattedError: string, error: ErrorObject) => string;

declare namespace SchemaUtils {
class ValidateError extends Error {
constructor(errors: Array<ErrorObject>, schema: Schema, configuration?: Partial<ValidateErrorConfiguration>);

name: string;
errors: Array<ErrorObject>;
schema: Schema;
headerName: string;
baseDataPath: string;
postFormatter: PostFormatter | null;
message: string;
}

interface ValidateErrorConfiguration {
name: string,
baseDataPath: string,
postFormatter: PostFormatter
}
}

declare var validate: {
(schema: Schema, options: Array<object> | object, configuration?: Partial<SchemaUtils.ValidateErrorConfiguration>): void;
ValidateError: typeof SchemaUtils.ValidateError
}

export = validate;
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -8,6 +8,7 @@
"homepage": "https://github.com/webpack/schema-utils",
"bugs": "https://github.com/webpack/schema-utils/issues",
"main": "dist/index.js",
"types": "index.d.ts",
"engines": {
"node": ">= 8.9.0"
},
Expand Down Expand Up @@ -43,6 +44,7 @@
"@babel/preset-env": "^7.6.2",
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"@types/json-schema": "^7.0.3",
"@webpack-contrib/defaults": "^5.0.2",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-jest": "^24.9.0",
Expand Down

0 comments on commit facb431

Please sign in to comment.