mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Expand parameter types to match js.spec library.
Remove un-exported spec.finite
This commit is contained in:
12
types/js.spec/index.d.ts
vendored
12
types/js.spec/index.d.ts
vendored
@@ -71,7 +71,7 @@ export interface Problem {
|
||||
* @param value the value to test
|
||||
* @returns true if valid
|
||||
*/
|
||||
export function valid(spec: Spec, value: any): boolean;
|
||||
export function valid(spec: spec.SpecInput, value: any): boolean;
|
||||
|
||||
/**
|
||||
* Returns the conformed value to this spec.
|
||||
@@ -79,7 +79,7 @@ export function valid(spec: Spec, value: any): boolean;
|
||||
* @param value the value to test
|
||||
* @returns if the value does not conform to the spec, or the conformed value if it does.
|
||||
*/
|
||||
export function conform(spec: Spec, value: any): any;
|
||||
export function conform(spec: spec.SpecInput, value: any): any;
|
||||
|
||||
/**
|
||||
* Like explain(), but returns Problems array.
|
||||
@@ -87,28 +87,28 @@ export function conform(spec: Spec, value: any): any;
|
||||
* @param value the value to test
|
||||
* @returns list of problems or null if none
|
||||
*/
|
||||
export function explainData(spec: Spec, value: any): Problem[];
|
||||
export function explainData(spec: spec.SpecInput, value: any): Problem[];
|
||||
|
||||
/**
|
||||
* Prints, to the console, reasons why the value did not conform to this spec.
|
||||
* @param spec the spec to test with
|
||||
* @param value the value to test
|
||||
*/
|
||||
export function explain(spec: Spec, value: any): void;
|
||||
export function explain(spec: spec.SpecInput, value: any): void;
|
||||
|
||||
/**
|
||||
* Returns a multiline string with reasons why the value did not conform to this spec.
|
||||
* @param spec the spec to test with
|
||||
* @param value the value to test
|
||||
*/
|
||||
export function explainStr(spec: Spec, value: any): string;
|
||||
export function explainStr(spec: spec.SpecInput, value: any): string;
|
||||
|
||||
/**
|
||||
* Tests if a value conforms to a spec, and if not, throws an Error.
|
||||
* @param spec the spec to test with
|
||||
* @param value the value to test
|
||||
*/
|
||||
export function assert(spec: Spec, value: any): void;
|
||||
export function assert(spec: spec.SpecInput, value: any): void;
|
||||
|
||||
export namespace symbol {
|
||||
/**
|
||||
|
||||
@@ -7,20 +7,28 @@ const name: string = spec.name;
|
||||
const options: object = spec.options;
|
||||
|
||||
const isValid: boolean = S.valid(S.spec.boolean, true);
|
||||
S.valid((value) => true, "a value");
|
||||
|
||||
const result = S.conform(S.spec.map("dancing", {field: S.spec.string}), "not a map");
|
||||
S.conform((value) => true, "a value");
|
||||
|
||||
const problems: S.Problem[] = S.explainData(S.spec.int, "not a number");
|
||||
S.explainData((value) => true, "a value");
|
||||
|
||||
const {path, via, value, predicate}: {path: string[], via: string[], value: any, predicate: S.Predicate} = problems[0];
|
||||
|
||||
const problemStr: string = S.explainStr(S.spec.even, 3);
|
||||
S.explainStr((value) => true, "a value");
|
||||
|
||||
// $ExpectType void
|
||||
S.explain(S.spec.positive, true);
|
||||
// $ExpectType void
|
||||
S.explain((value) => true, "a value");
|
||||
|
||||
// $ExpectType void
|
||||
S.assert(S.spec.string, "things");
|
||||
// $ExpectType void
|
||||
S.assert((value) => true, "a value");
|
||||
|
||||
const symbols: symbol[] = [S.symbol.count, S.symbol.invalid, S.symbol.maxCount, S.symbol.minCount, S.symbol.optional];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user