add typings for spected

This commit is contained in:
Benjamin Makus
2019-01-08 03:09:00 +01:00
parent 009ff6e86b
commit 7c8b923faa
3 changed files with 17 additions and 13 deletions

View File

@@ -1,26 +1,30 @@
// Type definitions for yup 0.26
// Type definitions for spected 0.26
// Project: https://github.com/25th-floor/spected
// Definitions by: Benjamin Makus <https://github.com/benneq>,
// Definitions by: Benjamin Makus <https://github.com/benneq>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.2
// TypeScript Version: 2.1
declare var spected: Spected;
export type Spected = (spec: Spec, input: any) => Result
export type Spected = (spec: Spec, input: any) => Result;
export type Predicate = (value: any, inputs: any) => boolean
export type Predicate = (value: any, inputs: any) => boolean;
export type ErrorMsg =
| string
| ((value: any, field: string) => string)
| ((value: any, field: string) => string);
export type Spec = {[key: string]: SpecValue }
export interface Spec {
[key: string]: SpecValue;
}
export type SpecValue =
export type SpecValue =
| ReadonlyArray<[Predicate, ErrorMsg]>
| ((value: any) => any)
| Spec
| Spec;
export type Result = {[key: string]: true | Array<string> | Result}
export interface Result {
[key: string]: true | string[] | Result;
}
export default spected;
export default spected;

View File

@@ -7,6 +7,7 @@
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -16,7 +17,6 @@
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"spected-tests.ts"
"index.d.ts"
]
}