Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: definitions #52

Merged
merged 3 commits into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 32 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't add some types in devDeps?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@types/json-schema

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I just followed your previous suggestions -( Ok i will revert this and move this to dev dependency

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vankop Sometimes I have a lot issues and lose context, sorry for that, all make mistakes 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is fine

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
Original file line number Diff line number Diff line change
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