Skip to content

Commit facb431

Browse files
vankopevilebottnawi
authored andcommitted
feat: types definitions (#52)
1 parent ba01fe5 commit facb431

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

index.d.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import {JSONSchema4, JSONSchema6, JSONSchema7} from 'json-schema';
2+
import {ErrorObject} from 'ajv';
3+
4+
type Schema = JSONSchema4 | JSONSchema6 | JSONSchema7;
5+
type PostFormatter = (formattedError: string, error: ErrorObject) => string;
6+
7+
declare namespace SchemaUtils {
8+
class ValidateError extends Error {
9+
constructor(errors: Array<ErrorObject>, schema: Schema, configuration?: Partial<ValidateErrorConfiguration>);
10+
11+
name: string;
12+
errors: Array<ErrorObject>;
13+
schema: Schema;
14+
headerName: string;
15+
baseDataPath: string;
16+
postFormatter: PostFormatter | null;
17+
message: string;
18+
}
19+
20+
interface ValidateErrorConfiguration {
21+
name: string,
22+
baseDataPath: string,
23+
postFormatter: PostFormatter
24+
}
25+
}
26+
27+
declare var validate: {
28+
(schema: Schema, options: Array<object> | object, configuration?: Partial<SchemaUtils.ValidateErrorConfiguration>): void;
29+
ValidateError: typeof SchemaUtils.ValidateError
30+
}
31+
32+
export = validate;

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"homepage": "https://github.com/webpack/schema-utils",
99
"bugs": "https://github.com/webpack/schema-utils/issues",
1010
"main": "dist/index.js",
11+
"types": "index.d.ts",
1112
"engines": {
1213
"node": ">= 8.9.0"
1314
},
@@ -43,6 +44,7 @@
4344
"@babel/preset-env": "^7.6.2",
4445
"@commitlint/cli": "^8.2.0",
4546
"@commitlint/config-conventional": "^8.2.0",
47+
"@types/json-schema": "^7.0.3",
4648
"@webpack-contrib/defaults": "^5.0.2",
4749
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
4850
"babel-jest": "^24.9.0",

0 commit comments

Comments
 (0)