Comparing version 0.12.0 to 0.13.0
@@ -58,3 +58,3 @@ import { Runtype } from './runtype'; | ||
underlying: Reflect; | ||
constraint: ConstraintCheck<Reflect>; | ||
constraint: ConstraintCheck<Runtype<always>>; | ||
args?: any; | ||
@@ -64,2 +64,2 @@ } & Runtype<always> | { | ||
ctor: Constructor; | ||
} & Runtype<any>; | ||
} & Runtype<always>; |
@@ -6,3 +6,3 @@ import { Result, Union2, Intersect2, Constraint, ConstraintCheck } from './index'; | ||
*/ | ||
export interface Runtype<A> { | ||
export interface Runtype<A = any> { | ||
/** | ||
@@ -25,7 +25,7 @@ * Verifies that a value conforms to this runtype. If so, returns the same value, | ||
*/ | ||
Or<B extends Rt>(B: B): Union2<this, B>; | ||
Or<B extends Runtype>(B: B): Union2<this, B>; | ||
/** | ||
* Intersect this Runtype with another. | ||
*/ | ||
And<B extends Rt>(B: B): Intersect2<this, B>; | ||
And<B extends Runtype>(B: B): Intersect2<this, B>; | ||
/** | ||
@@ -45,10 +45,6 @@ * Provide a function which validates some arbitrary constraint, | ||
/** | ||
* Just a convenient synonym for internal use in defining new Runtypes. | ||
*/ | ||
export declare type Rt = Runtype<any>; | ||
/** | ||
* Obtains the static type associated with a Runtype. | ||
*/ | ||
export declare type Static<A extends Rt> = A['_falseWitness']; | ||
export declare function create<A extends Rt>(check: (x: {}) => Static<A>, A: any): A; | ||
export declare type Static<A extends Runtype> = A['_falseWitness']; | ||
export declare function create<A extends Runtype>(check: (x: {}) => Static<A>, A: any): A; | ||
export declare class ValidationError extends Error { | ||
@@ -55,0 +51,0 @@ constructor(message: string); |
@@ -49,3 +49,3 @@ "use strict"; | ||
exports.create = create; | ||
var ValidationError = (function (_super) { | ||
var ValidationError = /** @class */ (function (_super) { | ||
__extends(ValidationError, _super); | ||
@@ -52,0 +52,0 @@ function ValidationError(message) { |
@@ -47,6 +47,6 @@ "use strict"; | ||
case 'instanceof': | ||
var name_1 = refl.ctor.name; | ||
return "InstanceOf<" + (name_1) + ">"; | ||
var name = refl.ctor.name; | ||
return "InstanceOf<" + (name) + ">"; | ||
} | ||
}; }; | ||
exports.default = show(false); |
@@ -1,3 +0,3 @@ | ||
import { Runtype, Rt, Static } from '../runtype'; | ||
interface Arr<E extends Rt> extends Runtype<Static<E>[]> { | ||
import { Runtype, Static } from '../runtype'; | ||
interface Arr<E extends Runtype> extends Runtype<Static<E>[]> { | ||
tag: 'array'; | ||
@@ -9,3 +9,3 @@ element: E; | ||
*/ | ||
declare function Arr<E extends Rt>(element: E): Arr<E>; | ||
declare function Arr<E extends Runtype>(element: E): Arr<E>; | ||
export { Arr as Array }; |
@@ -1,9 +0,9 @@ | ||
import { Runtype, Rt, Static } from '../runtype'; | ||
export declare type ConstraintCheck<A extends Rt> = (x: Static<A>) => boolean | string; | ||
export interface Constraint<A extends Rt, K> extends Runtype<Static<A>> { | ||
import { Runtype, Static } from '../runtype'; | ||
export declare type ConstraintCheck<A extends Runtype> = (x: Static<A>) => boolean | string; | ||
export interface Constraint<A extends Runtype, K> extends Runtype<Static<A>> { | ||
tag: 'constraint'; | ||
underlying: A; | ||
constraint: ConstraintCheck<A>; | ||
constraint(x: Static<A>): boolean | string; | ||
args?: K; | ||
} | ||
export declare function Constraint<A extends Rt, K>(underlying: A, constraint: ConstraintCheck<A>, args?: K): Constraint<A, K>; | ||
export declare function Constraint<A extends Runtype, K>(underlying: A, constraint: ConstraintCheck<A>, args?: K): Constraint<A, K>; |
@@ -1,3 +0,3 @@ | ||
import { Runtype, Rt, Static } from '../runtype'; | ||
export interface StringDictionary<V extends Rt> extends Runtype<{ | ||
import { Runtype, Static } from '../runtype'; | ||
export interface StringDictionary<V extends Runtype> extends Runtype<{ | ||
[_: string]: Static<V>; | ||
@@ -9,3 +9,3 @@ }> { | ||
} | ||
export interface NumberDictionary<V extends Rt> extends Runtype<{ | ||
export interface NumberDictionary<V extends Runtype> extends Runtype<{ | ||
[_: number]: Static<V>; | ||
@@ -20,3 +20,3 @@ }> { | ||
*/ | ||
export declare function Dictionary<V extends Rt>(v: V, key?: 'string'): StringDictionary<V>; | ||
export declare function Dictionary<V extends Rt>(v: V, key?: 'number'): NumberDictionary<V>; | ||
export declare function Dictionary<V extends Runtype>(value: V, key?: 'string'): StringDictionary<V>; | ||
export declare function Dictionary<V extends Runtype>(value: V, key?: 'number'): NumberDictionary<V>; |
@@ -1,39 +0,39 @@ | ||
import { Runtype, Rt, Static } from '../runtype'; | ||
export interface Intersect1<A extends Rt> extends Runtype<Static<A>> { | ||
import { Runtype, Static } from '../runtype'; | ||
export interface Intersect1<A extends Runtype> extends Runtype<Static<A>> { | ||
tag: 'intersect'; | ||
intersectees: [A]; | ||
} | ||
export interface Intersect2<A extends Rt, B extends Rt> extends Runtype<Static<A> & Static<B>> { | ||
export interface Intersect2<A extends Runtype, B extends Runtype> extends Runtype<Static<A> & Static<B>> { | ||
tag: 'intersect'; | ||
intersectees: [A, B]; | ||
} | ||
export interface Intersect3<A extends Rt, B extends Rt, C extends Rt> extends Runtype<Static<A> & Static<B> & Static<C>> { | ||
export interface Intersect3<A extends Runtype, B extends Runtype, C extends Runtype> extends Runtype<Static<A> & Static<B> & Static<C>> { | ||
tag: 'intersect'; | ||
intersectees: [A, B, C]; | ||
} | ||
export interface Intersect4<A extends Rt, B extends Rt, C extends Rt, D extends Rt> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D>> { | ||
export interface Intersect4<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D>> { | ||
tag: 'intersect'; | ||
intersectees: [A, B, C, D]; | ||
} | ||
export interface Intersect5<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E>> { | ||
export interface Intersect5<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E>> { | ||
tag: 'intersect'; | ||
intersectees: [A, B, C, D, E]; | ||
} | ||
export interface Intersect6<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F>> { | ||
export interface Intersect6<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F>> { | ||
tag: 'intersect'; | ||
intersectees: [A, B, C, D, E, F]; | ||
} | ||
export interface Intersect7<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G>> { | ||
export interface Intersect7<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G>> { | ||
tag: 'intersect'; | ||
intersectees: [A, B, C, D, E, F, G]; | ||
} | ||
export interface Intersect8<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G> & Static<H>> { | ||
export interface Intersect8<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G> & Static<H>> { | ||
tag: 'intersect'; | ||
intersectees: [A, B, C, D, E, F, G, H]; | ||
} | ||
export interface Intersect9<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G> & Static<H> & Static<I>> { | ||
export interface Intersect9<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G> & Static<H> & Static<I>> { | ||
tag: 'intersect'; | ||
intersectees: [A, B, C, D, E, F, G, H, I]; | ||
} | ||
export interface Intersect10<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G> & Static<H> & Static<I> & Static<J>> { | ||
export interface Intersect10<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype> extends Runtype<Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G> & Static<H> & Static<I> & Static<J>> { | ||
tag: 'intersect'; | ||
@@ -45,11 +45,11 @@ intersectees: [A, B, C, D, E, F, G, H, I, J]; | ||
*/ | ||
export declare function Intersect<A extends Rt>(A: A): Intersect1<A>; | ||
export declare function Intersect<A extends Rt, B extends Rt>(A: A, B: B): Intersect2<A, B>; | ||
export declare function Intersect<A extends Rt, B extends Rt, C extends Rt>(A: A, B: B, C: C): Intersect3<A, B, C>; | ||
export declare function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt>(A: A, B: B, C: C, D: D): Intersect4<A, B, C, D>; | ||
export declare function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt>(A: A, B: B, C: C, D: D, E: E): Intersect5<A, B, C, D, E>; | ||
export declare function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F): Intersect6<A, B, C, D, E, F>; | ||
export declare function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G): Intersect7<A, B, C, D, E, F, G>; | ||
export declare function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H): Intersect8<A, B, C, D, E, F, G, H>; | ||
export declare function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I): Intersect9<A, B, C, D, E, F, G, H, I>; | ||
export declare function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, J: J): Intersect10<A, B, C, D, E, F, G, H, I, J>; | ||
export declare function Intersect<A extends Runtype>(A: A): Intersect1<A>; | ||
export declare function Intersect<A extends Runtype, B extends Runtype>(A: A, B: B): Intersect2<A, B>; | ||
export declare function Intersect<A extends Runtype, B extends Runtype, C extends Runtype>(A: A, B: B, C: C): Intersect3<A, B, C>; | ||
export declare function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype>(A: A, B: B, C: C, D: D): Intersect4<A, B, C, D>; | ||
export declare function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype>(A: A, B: B, C: C, D: D, E: E): Intersect5<A, B, C, D, E>; | ||
export declare function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F): Intersect6<A, B, C, D, E, F>; | ||
export declare function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G): Intersect7<A, B, C, D, E, F, G>; | ||
export declare function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H): Intersect8<A, B, C, D, E, F, G, H>; | ||
export declare function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I): Intersect9<A, B, C, D, E, F, G, H, I>; | ||
export declare function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, J: J): Intersect10<A, B, C, D, E, F, G, H, I, J>; |
@@ -1,5 +0,5 @@ | ||
import { Rt } from '../runtype'; | ||
import { Runtype } from '../runtype'; | ||
/** | ||
* Construct a possibly-recursive Runtype. | ||
*/ | ||
export declare function Lazy<A extends Rt>(delayed: () => A): A; | ||
export declare function Lazy<A extends Runtype>(delayed: () => A): A; |
@@ -1,4 +0,4 @@ | ||
import { Runtype, Rt, Static } from '../runtype'; | ||
import { Runtype, Static } from '../runtype'; | ||
export interface Part<O extends { | ||
[_ in string]: Rt; | ||
[_ in string]: Runtype; | ||
}> extends Runtype<{ | ||
@@ -14,4 +14,4 @@ [K in keyof O]?: Static<O[K]>; | ||
export declare function Part<O extends { | ||
[_: string]: Rt; | ||
[_: string]: Runtype; | ||
}>(fields: O): Part<O>; | ||
export { Part as Partial }; |
@@ -1,4 +0,4 @@ | ||
import { Runtype, Rt, Static } from '../runtype'; | ||
import { Runtype, Static } from '../runtype'; | ||
export interface Record<O extends { | ||
[_ in string]: Rt; | ||
[_ in string]: Runtype; | ||
}> extends Runtype<{ | ||
@@ -14,3 +14,3 @@ [K in keyof O]: Static<O[K]>; | ||
export declare function Record<O extends { | ||
[_: string]: Rt; | ||
[_: string]: Runtype; | ||
}>(fields: O): Record<O>; |
@@ -1,39 +0,39 @@ | ||
import { Runtype, Rt, Static } from '../runtype'; | ||
export interface Tuple1<A extends Rt> extends Runtype<[Static<A>]> { | ||
import { Runtype, Static } from '../runtype'; | ||
export interface Tuple1<A extends Runtype> extends Runtype<[Static<A>]> { | ||
tag: 'tuple'; | ||
components: [A]; | ||
} | ||
export interface Tuple2<A extends Rt, B extends Rt> extends Runtype<[Static<A>, Static<B>]> { | ||
export interface Tuple2<A extends Runtype, B extends Runtype> extends Runtype<[Static<A>, Static<B>]> { | ||
tag: 'tuple'; | ||
components: [A, B]; | ||
} | ||
export interface Tuple3<A extends Rt, B extends Rt, C extends Rt> extends Runtype<[Static<A>, Static<B>, Static<C>]> { | ||
export interface Tuple3<A extends Runtype, B extends Runtype, C extends Runtype> extends Runtype<[Static<A>, Static<B>, Static<C>]> { | ||
tag: 'tuple'; | ||
components: [A, B, C]; | ||
} | ||
export interface Tuple4<A extends Rt, B extends Rt, C extends Rt, D extends Rt> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>]> { | ||
export interface Tuple4<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>]> { | ||
tag: 'tuple'; | ||
components: [A, B, C, D]; | ||
} | ||
export interface Tuple5<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>]> { | ||
export interface Tuple5<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>]> { | ||
tag: 'tuple'; | ||
components: [A, B, C, D, E]; | ||
} | ||
export interface Tuple6<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>]> { | ||
export interface Tuple6<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>]> { | ||
tag: 'tuple'; | ||
components: [A, B, C, D, E, F]; | ||
} | ||
export interface Tuple7<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>]> { | ||
export interface Tuple7<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>]> { | ||
tag: 'tuple'; | ||
components: [A, B, C, D, E, F, G]; | ||
} | ||
export interface Tuple8<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>, Static<H>]> { | ||
export interface Tuple8<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>, Static<H>]> { | ||
tag: 'tuple'; | ||
components: [A, B, C, D, E, F, G, H]; | ||
} | ||
export interface Tuple9<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>, Static<H>, Static<I>]> { | ||
export interface Tuple9<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>, Static<H>, Static<I>]> { | ||
tag: 'tuple'; | ||
components: [A, B, C, D, E, F, G, H, I]; | ||
} | ||
export interface Tuple10<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>, Static<H>, Static<I>, Static<J>]> { | ||
export interface Tuple10<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype> extends Runtype<[Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>, Static<H>, Static<I>, Static<J>]> { | ||
tag: 'tuple'; | ||
@@ -45,11 +45,11 @@ components: [A, B, C, D, E, F, G, H, I, J]; | ||
*/ | ||
export declare function Tuple<A extends Rt>(A: A): Tuple1<A>; | ||
export declare function Tuple<A extends Rt, B extends Rt>(A: A, B: B): Tuple2<A, B>; | ||
export declare function Tuple<A extends Rt, B extends Rt, C extends Rt>(A: A, B: B, C: C): Tuple3<A, B, C>; | ||
export declare function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt>(A: A, B: B, C: C, D: D): Tuple4<A, B, C, D>; | ||
export declare function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt>(A: A, B: B, C: C, D: D, E: E): Tuple5<A, B, C, D, E>; | ||
export declare function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F): Tuple6<A, B, C, D, E, F>; | ||
export declare function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G): Tuple7<A, B, C, D, E, F, G>; | ||
export declare function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H): Tuple8<A, B, C, D, E, F, G, H>; | ||
export declare function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I): Tuple9<A, B, C, D, E, F, G, H, I>; | ||
export declare function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, J: J): Tuple10<A, B, C, D, E, F, G, H, I, J>; | ||
export declare function Tuple<A extends Runtype>(A: A): Tuple1<A>; | ||
export declare function Tuple<A extends Runtype, B extends Runtype>(A: A, B: B): Tuple2<A, B>; | ||
export declare function Tuple<A extends Runtype, B extends Runtype, C extends Runtype>(A: A, B: B, C: C): Tuple3<A, B, C>; | ||
export declare function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype>(A: A, B: B, C: C, D: D): Tuple4<A, B, C, D>; | ||
export declare function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype>(A: A, B: B, C: C, D: D, E: E): Tuple5<A, B, C, D, E>; | ||
export declare function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F): Tuple6<A, B, C, D, E, F>; | ||
export declare function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G): Tuple7<A, B, C, D, E, F, G>; | ||
export declare function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H): Tuple8<A, B, C, D, E, F, G, H>; | ||
export declare function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I): Tuple9<A, B, C, D, E, F, G, H, I>; | ||
export declare function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, J: J): Tuple10<A, B, C, D, E, F, G, H, I, J>; |
@@ -1,39 +0,39 @@ | ||
import { Runtype, Rt, Static } from '../runtype'; | ||
export interface Union1<A extends Rt> extends Runtype<Static<A>> { | ||
import { Runtype, Static } from '../runtype'; | ||
export interface Union1<A extends Runtype> extends Runtype<Static<A>> { | ||
tag: 'union'; | ||
alternatives: [A]; | ||
} | ||
export interface Union2<A extends Rt, B extends Rt> extends Runtype<Static<A> | Static<B>> { | ||
export interface Union2<A extends Runtype, B extends Runtype> extends Runtype<Static<A> | Static<B>> { | ||
tag: 'union'; | ||
alternatives: [A, B]; | ||
} | ||
export interface Union3<A extends Rt, B extends Rt, C extends Rt> extends Runtype<Static<A> | Static<B> | Static<C>> { | ||
export interface Union3<A extends Runtype, B extends Runtype, C extends Runtype> extends Runtype<Static<A> | Static<B> | Static<C>> { | ||
tag: 'union'; | ||
alternatives: [A, B, C]; | ||
} | ||
export interface Union4<A extends Rt, B extends Rt, C extends Rt, D extends Rt> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D>> { | ||
export interface Union4<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D>> { | ||
tag: 'union'; | ||
alternatives: [A, B, C, D]; | ||
} | ||
export interface Union5<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E>> { | ||
export interface Union5<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E>> { | ||
tag: 'union'; | ||
alternatives: [A, B, C, D, E]; | ||
} | ||
export interface Union6<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F>> { | ||
export interface Union6<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F>> { | ||
tag: 'union'; | ||
alternatives: [A, B, C, D, E, F]; | ||
} | ||
export interface Union7<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G>> { | ||
export interface Union7<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G>> { | ||
tag: 'union'; | ||
alternatives: [A, B, C, D, E, F, G]; | ||
} | ||
export interface Union8<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G> | Static<H>> { | ||
export interface Union8<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G> | Static<H>> { | ||
tag: 'union'; | ||
alternatives: [A, B, C, D, E, F, G, H]; | ||
} | ||
export interface Union9<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G> | Static<H> | Static<I>> { | ||
export interface Union9<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G> | Static<H> | Static<I>> { | ||
tag: 'union'; | ||
alternatives: [A, B, C, D, E, F, G, H, I]; | ||
} | ||
export interface Union10<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G> | Static<H> | Static<I> | Static<J>> { | ||
export interface Union10<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype> extends Runtype<Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G> | Static<H> | Static<I> | Static<J>> { | ||
tag: 'union'; | ||
@@ -45,11 +45,11 @@ alternatives: [A, B, C, D, E, F, G, H, I, J]; | ||
*/ | ||
export declare function Union<A extends Rt>(A: A): Union1<A>; | ||
export declare function Union<A extends Rt, B extends Rt>(A: A, B: B): Union2<A, B>; | ||
export declare function Union<A extends Rt, B extends Rt, C extends Rt>(A: A, B: B, C: C): Union3<A, B, C>; | ||
export declare function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt>(A: A, B: B, C: C, D: D): Union4<A, B, C, D>; | ||
export declare function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt>(A: A, B: B, C: C, D: D, E: E): Union5<A, B, C, D, E>; | ||
export declare function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F): Union6<A, B, C, D, E, F>; | ||
export declare function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G): Union7<A, B, C, D, E, F, G>; | ||
export declare function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H): Union8<A, B, C, D, E, F, G, H>; | ||
export declare function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I): Union9<A, B, C, D, E, F, G, H, I>; | ||
export declare function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, J: J): Union10<A, B, C, D, E, F, G, H, I, J>; | ||
export declare function Union<A extends Runtype>(A: A): Union1<A>; | ||
export declare function Union<A extends Runtype, B extends Runtype>(A: A, B: B): Union2<A, B>; | ||
export declare function Union<A extends Runtype, B extends Runtype, C extends Runtype>(A: A, B: B, C: C): Union3<A, B, C>; | ||
export declare function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype>(A: A, B: B, C: C, D: D): Union4<A, B, C, D>; | ||
export declare function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype>(A: A, B: B, C: C, D: D, E: E): Union5<A, B, C, D, E>; | ||
export declare function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F): Union6<A, B, C, D, E, F>; | ||
export declare function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G): Union7<A, B, C, D, E, F, G>; | ||
export declare function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H): Union8<A, B, C, D, E, F, G, H>; | ||
export declare function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I): Union9<A, B, C, D, E, F, G, H, I>; | ||
export declare function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype>(A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, J: J): Union10<A, B, C, D, E, F, G, H, I, J>; |
{ | ||
"name": "runtypes", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "Runtime validation for static types", | ||
@@ -17,7 +17,7 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@types/jest": "20.0.2", | ||
"coveralls": "^2.13.0", | ||
"jest": "20.0.4", | ||
"ts-jest": "^20.0.7", | ||
"typescript": "2.4.1" | ||
"@types/jest": "21.1.5", | ||
"coveralls": "^3.0.0", | ||
"jest": "21.2.1", | ||
"ts-jest": "^21.1.4", | ||
"typescript": "2.6.1" | ||
}, | ||
@@ -24,0 +24,0 @@ "keywords:": [ |
@@ -161,3 +161,3 @@ import { Runtype } from './index' | ||
): Contract10<A, B, C, D, E, F, G, H, I, J, Z> | ||
export function Contract(...runtypes: Runtype<any>[]) { | ||
export function Contract(...runtypes: Runtype[]) { | ||
const lastIndex = runtypes.length - 1 | ||
@@ -164,0 +164,0 @@ const argTypes = runtypes.slice(0, lastIndex) |
@@ -23,3 +23,3 @@ import { Runtype } from './runtype' | ||
| { tag: 'function' } & Runtype<(...args: any[]) => any> | ||
| { tag: 'constraint'; underlying: Reflect; constraint: ConstraintCheck<Reflect>; args?: any } & Runtype<always> | ||
| { tag: 'instanceof', ctor: Constructor } & Runtype<any> | ||
| { tag: 'constraint'; underlying: Reflect; constraint: ConstraintCheck<Runtype<always>>; args?: any } & Runtype<always> | ||
| { tag: 'instanceof', ctor: Constructor } & Runtype<always> |
@@ -8,3 +8,3 @@ import { Result, Union, Union2, Intersect, Intersect2, Constraint, ConstraintCheck } from './index' | ||
*/ | ||
export interface Runtype<A> { | ||
export interface Runtype<A = any> { | ||
/** | ||
@@ -30,3 +30,3 @@ * Verifies that a value conforms to this runtype. If so, returns the same value, | ||
*/ | ||
Or<B extends Rt>(B: B): Union2<this, B> | ||
Or<B extends Runtype>(B: B): Union2<this, B> | ||
@@ -36,3 +36,3 @@ /** | ||
*/ | ||
And<B extends Rt>(B: B): Intersect2<this, B> | ||
And<B extends Runtype>(B: B): Intersect2<this, B> | ||
@@ -56,12 +56,7 @@ /** | ||
/** | ||
* Just a convenient synonym for internal use in defining new Runtypes. | ||
*/ | ||
export type Rt = Runtype<any> | ||
/** | ||
* Obtains the static type associated with a Runtype. | ||
*/ | ||
export type Static<A extends Rt> = A['_falseWitness'] | ||
export type Static<A extends Runtype> = A['_falseWitness'] | ||
export function create<A extends Rt>(check: (x: {}) => Static<A>, A: any): A { | ||
export function create<A extends Runtype>(check: (x: {}) => Static<A>, A: any): A { | ||
@@ -92,7 +87,7 @@ A.check = check | ||
function Or<B extends Rt>(B: B): Union2<A, B> { | ||
function Or<B extends Runtype>(B: B): Union2<A, B> { | ||
return Union(A, B) | ||
} | ||
function And<B extends Rt>(B: B): Intersect2<A, B> { | ||
function And<B extends Runtype>(B: B): Intersect2<A, B> { | ||
return Intersect(A, B) | ||
@@ -99,0 +94,0 @@ } |
@@ -1,4 +0,4 @@ | ||
import { Runtype, Rt, Static, create, validationError } from '../runtype' | ||
import { Runtype, Static, create, validationError } from '../runtype' | ||
interface Arr<E extends Rt> extends Runtype<Static<E>[]> { | ||
interface Arr<E extends Runtype> extends Runtype<Static<E>[]> { | ||
tag: 'array' | ||
@@ -11,3 +11,3 @@ element: E | ||
*/ | ||
function Arr<E extends Rt>(element: E): Arr<E> { | ||
function Arr<E extends Runtype>(element: E): Arr<E> { | ||
return create<Arr<E>>(xs => { | ||
@@ -14,0 +14,0 @@ if (!Array.isArray(xs)) |
@@ -1,14 +0,16 @@ | ||
import { Runtype, Rt, Static, create, validationError } from '../runtype' | ||
import { Runtype, Static, create, validationError } from '../runtype' | ||
import { String } from './string' | ||
export type ConstraintCheck<A extends Rt> = (x: Static<A>) => boolean | string | ||
export type ConstraintCheck<A extends Runtype> = (x: Static<A>) => boolean | string | ||
export interface Constraint<A extends Rt, K> extends Runtype<Static<A>> { | ||
export interface Constraint<A extends Runtype, K> extends Runtype<Static<A>> { | ||
tag: 'constraint' | ||
underlying: A, | ||
constraint: ConstraintCheck<A>, | ||
// See: https://github.com/Microsoft/TypeScript/issues/19746 for why this isn't just | ||
// `constraint: ConstraintCheck<A>` | ||
constraint(x: Static<A>): boolean | string, | ||
args?: K | ||
} | ||
export function Constraint<A extends Rt, K>(underlying: A, constraint: ConstraintCheck<A>, args?: K) { | ||
export function Constraint<A extends Runtype, K>(underlying: A, constraint: ConstraintCheck<A>, args?: K) { | ||
return create<Constraint<A, K>>(x => { | ||
@@ -15,0 +17,0 @@ const typed = underlying.check(x) |
@@ -1,5 +0,5 @@ | ||
import { Runtype, create, Rt, Static, validationError } from '../runtype' | ||
import { Runtype, create, Static, validationError } from '../runtype' | ||
import { Record } from './record' | ||
export interface StringDictionary<V extends Rt> extends Runtype<{ [_: string]: Static<V> }> { | ||
export interface StringDictionary<V extends Runtype> extends Runtype<{ [_: string]: Static<V> }> { | ||
tag: 'dictionary' | ||
@@ -10,3 +10,3 @@ key: 'string' | ||
export interface NumberDictionary<V extends Rt> extends Runtype<{ [_: number]: Static<V> }> { | ||
export interface NumberDictionary<V extends Runtype> extends Runtype<{ [_: number]: Static<V> }> { | ||
tag: 'dictionary' | ||
@@ -20,6 +20,6 @@ key: 'number' | ||
*/ | ||
export function Dictionary<V extends Rt>(v: V, key?: 'string'): StringDictionary<V> | ||
export function Dictionary<V extends Rt>(v: V, key?: 'number'): NumberDictionary<V> | ||
export function Dictionary<V extends Rt>(value: V, key = 'string') { | ||
return create<Rt>(x => { | ||
export function Dictionary<V extends Runtype>(value: V, key?: 'string'): StringDictionary<V> | ||
export function Dictionary<V extends Runtype>(value: V, key?: 'number'): NumberDictionary<V> | ||
export function Dictionary<V extends Runtype>(value: V, key = 'string'): any { | ||
return create<Runtype>(x => { | ||
Record({}).check(x) | ||
@@ -26,0 +26,0 @@ |
@@ -1,5 +0,5 @@ | ||
import { Runtype, Rt, Static, create } from '../runtype' | ||
import { Runtype, Static, create } from '../runtype' | ||
export interface Intersect1< | ||
A extends Rt, | ||
A extends Runtype, | ||
> extends Runtype< | ||
@@ -13,3 +13,3 @@ Static<A> | ||
export interface Intersect2< | ||
A extends Rt, B extends Rt, | ||
A extends Runtype, B extends Runtype, | ||
> extends Runtype< | ||
@@ -22,3 +22,3 @@ Static<A> & Static<B> | ||
export interface Intersect3< | ||
A extends Rt, B extends Rt, C extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, | ||
> extends Runtype< | ||
@@ -32,3 +32,3 @@ Static<A> & Static<B> & Static<C> | ||
export interface Intersect4< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, | ||
> extends Runtype< | ||
@@ -42,3 +42,3 @@ Static<A> & Static<B> & Static<C> & Static<D> | ||
export interface Intersect5< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, | ||
> extends Runtype< | ||
@@ -52,3 +52,3 @@ Static<A> & Static<B> & Static<C> & Static<D> & Static<E> | ||
export interface Intersect6< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, | ||
> extends Runtype< | ||
@@ -62,3 +62,3 @@ Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> | ||
export interface Intersect7< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, | ||
> extends Runtype< | ||
@@ -72,3 +72,3 @@ Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G> | ||
export interface Intersect8< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, | ||
> extends Runtype< | ||
@@ -82,3 +82,3 @@ Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G> & Static<H> | ||
export interface Intersect9< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, | ||
> extends Runtype< | ||
@@ -92,3 +92,3 @@ Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G> & Static<H> & Static<I> | ||
export interface Intersect10< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype, | ||
> extends Runtype< | ||
@@ -104,33 +104,33 @@ Static<A> & Static<B> & Static<C> & Static<D> & Static<E> & Static<F> & Static<G> & Static<H> & Static<I> & Static<J> | ||
*/ | ||
export function Intersect<A extends Rt>( | ||
export function Intersect<A extends Runtype>( | ||
A: A, | ||
): Intersect1<A> | ||
export function Intersect<A extends Rt, B extends Rt>( | ||
export function Intersect<A extends Runtype, B extends Runtype>( | ||
A: A, B: B, | ||
): Intersect2<A, B> | ||
export function Intersect<A extends Rt, B extends Rt, C extends Rt>( | ||
export function Intersect<A extends Runtype, B extends Runtype, C extends Runtype>( | ||
A: A, B: B, C: C, | ||
): Intersect3<A, B, C> | ||
export function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt>( | ||
export function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype>( | ||
A: A, B: B, C: C, D: D, | ||
): Intersect4<A, B, C, D> | ||
export function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt>( | ||
export function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, | ||
): Intersect5<A, B, C, D, E> | ||
export function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt>( | ||
export function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, | ||
): Intersect6<A, B, C, D, E, F> | ||
export function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt>( | ||
export function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, | ||
): Intersect7<A, B, C, D, E, F, G> | ||
export function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt>( | ||
export function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, | ||
): Intersect8<A, B, C, D, E, F, G, H> | ||
export function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt>( | ||
export function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, | ||
): Intersect9<A, B, C, D, E, F, G, H, I> | ||
export function Intersect<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt>( | ||
export function Intersect<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, J: J, | ||
): Intersect10<A, B, C, D, E, F, G, H, I, J> | ||
export function Intersect(...intersectees: Runtype<any>[]) { | ||
export function Intersect(...intersectees: Runtype[]): any { | ||
return create(x => { | ||
@@ -137,0 +137,0 @@ for (const { check } of intersectees) |
@@ -1,2 +0,2 @@ | ||
import { Rt, create } from '../runtype' | ||
import { Runtype, create } from '../runtype' | ||
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
export function Lazy<A extends Rt>(delayed: () => A) { | ||
export function Lazy<A extends Runtype>(delayed: () => A) { | ||
const data: any = { | ||
@@ -9,0 +9,0 @@ get tag() { return (getWrapped() as any)['tag'] } |
@@ -1,2 +0,2 @@ | ||
import { Runtype, Rt, Static, create, validationError } from '../runtype' | ||
import { Runtype, Static, create, validationError } from '../runtype' | ||
import { Union } from '../index' | ||
@@ -6,3 +6,3 @@ import { Undefined } from './literal' | ||
export interface Part<O extends {[_ in string]: Rt }> extends Runtype<{[K in keyof O]?: Static<O[K]> }> { | ||
export interface Part<O extends {[_ in string]: Runtype }> extends Runtype<{[K in keyof O]?: Static<O[K]> }> { | ||
tag: 'partial' | ||
@@ -15,3 +15,3 @@ fields: O | ||
*/ | ||
export function Part<O extends { [_: string]: Rt }>(fields: O) { | ||
export function Part<O extends { [_: string]: Runtype }>(fields: O) { | ||
return create<Part<O>>(x => { | ||
@@ -18,0 +18,0 @@ if (x === null || x === undefined) |
@@ -1,5 +0,5 @@ | ||
import { Runtype, Rt, Static, create, validationError } from '../runtype' | ||
import { Runtype, Static, create, validationError } from '../runtype' | ||
import { hasKey } from '../util' | ||
export interface Record<O extends { [_ in string]: Rt }> extends Runtype<{[K in keyof O]: Static<O[K]> }> { | ||
export interface Record<O extends { [_ in string]: Runtype }> extends Runtype<{[K in keyof O]: Static<O[K]> }> { | ||
tag: 'record' | ||
@@ -12,3 +12,3 @@ fields: O | ||
*/ | ||
export function Record<O extends { [_: string]: Rt }>(fields: O) { | ||
export function Record<O extends { [_: string]: Runtype }>(fields: O) { | ||
return create<Record<O>>(x => { | ||
@@ -15,0 +15,0 @@ if (x === null || x === undefined) |
@@ -1,2 +0,2 @@ | ||
import { Runtype, Rt, Static, create, validationError } from '../runtype' | ||
import { Runtype, Static, create, validationError } from '../runtype' | ||
import { Always } from './always' | ||
@@ -6,3 +6,3 @@ import { Array as Arr } from './array' | ||
export interface Tuple1< | ||
A extends Rt, | ||
A extends Runtype, | ||
> extends Runtype<[Static<A>]> { | ||
@@ -14,3 +14,3 @@ tag: 'tuple' | ||
export interface Tuple2< | ||
A extends Rt, B extends Rt, | ||
A extends Runtype, B extends Runtype, | ||
> extends Runtype<[ | ||
@@ -24,3 +24,3 @@ Static<A>, Static<B> | ||
export interface Tuple3< | ||
A extends Rt, B extends Rt, C extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, | ||
> extends Runtype<[ | ||
@@ -34,3 +34,3 @@ Static<A>, Static<B>, Static<C> | ||
export interface Tuple4< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, | ||
> extends Runtype<[ | ||
@@ -44,3 +44,3 @@ Static<A>, Static<B>, Static<C>, Static<D> | ||
export interface Tuple5< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, | ||
> extends Runtype<[ | ||
@@ -54,3 +54,3 @@ Static<A>, Static<B>, Static<C>, Static<D>, Static<E> | ||
export interface Tuple6< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, | ||
> extends Runtype<[ | ||
@@ -64,3 +64,3 @@ Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F> | ||
export interface Tuple7< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, | ||
> extends Runtype<[ | ||
@@ -74,3 +74,3 @@ Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G> | ||
export interface Tuple8< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, | ||
> extends Runtype<[ | ||
@@ -84,3 +84,3 @@ Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>, Static<H> | ||
export interface Tuple9< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, | ||
> extends Runtype<[ | ||
@@ -94,3 +94,3 @@ Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>, Static<H>, Static<I> | ||
export interface Tuple10< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype, | ||
> extends Runtype<[ | ||
@@ -106,33 +106,33 @@ Static<A>, Static<B>, Static<C>, Static<D>, Static<E>, Static<F>, Static<G>, Static<H>, Static<I>, Static<J> | ||
*/ | ||
export function Tuple<A extends Rt>( | ||
export function Tuple<A extends Runtype>( | ||
A: A, | ||
): Tuple1<A> | ||
export function Tuple<A extends Rt, B extends Rt>( | ||
export function Tuple<A extends Runtype, B extends Runtype>( | ||
A: A, B: B, | ||
): Tuple2<A, B> | ||
export function Tuple<A extends Rt, B extends Rt, C extends Rt>( | ||
export function Tuple<A extends Runtype, B extends Runtype, C extends Runtype>( | ||
A: A, B: B, C: C, | ||
): Tuple3<A, B, C> | ||
export function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt>( | ||
export function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype>( | ||
A: A, B: B, C: C, D: D, | ||
): Tuple4<A, B, C, D> | ||
export function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt>( | ||
export function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, | ||
): Tuple5<A, B, C, D, E> | ||
export function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt>( | ||
export function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, | ||
): Tuple6<A, B, C, D, E, F> | ||
export function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt>( | ||
export function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, | ||
): Tuple7<A, B, C, D, E, F, G> | ||
export function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt>( | ||
export function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, | ||
): Tuple8<A, B, C, D, E, F, G, H> | ||
export function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt>( | ||
export function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, | ||
): Tuple9<A, B, C, D, E, F, G, H, I> | ||
export function Tuple<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt>( | ||
export function Tuple<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, J: J, | ||
): Tuple10<A, B, C, D, E, F, G, H, I, J> | ||
export function Tuple(...components: Runtype<any>[]) { | ||
export function Tuple(...components: Runtype[]): any { | ||
return create(x => { | ||
@@ -139,0 +139,0 @@ const xs = Arr(Always).check(x) |
@@ -1,5 +0,5 @@ | ||
import { Runtype, Rt, Static, create } from '../runtype' | ||
import { Runtype, Static, create } from '../runtype' | ||
export interface Union1< | ||
A extends Rt, | ||
A extends Runtype, | ||
> extends Runtype< | ||
@@ -13,3 +13,3 @@ Static<A> | ||
export interface Union2< | ||
A extends Rt, B extends Rt, | ||
A extends Runtype, B extends Runtype, | ||
> extends Runtype< | ||
@@ -23,3 +23,3 @@ Static<A> | Static<B> | ||
export interface Union3< | ||
A extends Rt, B extends Rt, C extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, | ||
> extends Runtype< | ||
@@ -33,3 +33,3 @@ Static<A> | Static<B> | Static<C> | ||
export interface Union4< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, | ||
> extends Runtype< | ||
@@ -43,3 +43,3 @@ Static<A> | Static<B> | Static<C> | Static<D> | ||
export interface Union5< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, | ||
> extends Runtype< | ||
@@ -53,3 +53,3 @@ Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | ||
export interface Union6< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, | ||
> extends Runtype< | ||
@@ -63,3 +63,3 @@ Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | ||
export interface Union7< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, | ||
> extends Runtype< | ||
@@ -73,3 +73,3 @@ Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G> | ||
export interface Union8< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, | ||
> extends Runtype< | ||
@@ -83,3 +83,3 @@ Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G> | Static<H> | ||
export interface Union9< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, | ||
> extends Runtype< | ||
@@ -93,3 +93,3 @@ Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G> | Static<H> | Static<I> | ||
export interface Union10< | ||
A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt, | ||
A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype, | ||
> extends Runtype< | ||
@@ -105,33 +105,33 @@ Static<A> | Static<B> | Static<C> | Static<D> | Static<E> | Static<F> | Static<G> | Static<H> | Static<I> | Static<J> | ||
*/ | ||
export function Union<A extends Rt>( | ||
export function Union<A extends Runtype>( | ||
A: A, | ||
): Union1<A> | ||
export function Union<A extends Rt, B extends Rt>( | ||
export function Union<A extends Runtype, B extends Runtype>( | ||
A: A, B: B, | ||
): Union2<A, B> | ||
export function Union<A extends Rt, B extends Rt, C extends Rt>( | ||
export function Union<A extends Runtype, B extends Runtype, C extends Runtype>( | ||
A: A, B: B, C: C, | ||
): Union3<A, B, C> | ||
export function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt>( | ||
export function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype>( | ||
A: A, B: B, C: C, D: D, | ||
): Union4<A, B, C, D> | ||
export function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt>( | ||
export function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, | ||
): Union5<A, B, C, D, E> | ||
export function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt>( | ||
export function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, | ||
): Union6<A, B, C, D, E, F> | ||
export function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt>( | ||
export function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, | ||
): Union7<A, B, C, D, E, F, G> | ||
export function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt>( | ||
export function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, | ||
): Union8<A, B, C, D, E, F, G, H> | ||
export function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt>( | ||
export function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, | ||
): Union9<A, B, C, D, E, F, G, H, I> | ||
export function Union<A extends Rt, B extends Rt, C extends Rt, D extends Rt, E extends Rt, F extends Rt, G extends Rt, H extends Rt, I extends Rt, J extends Rt>( | ||
export function Union<A extends Runtype, B extends Runtype, C extends Runtype, D extends Runtype, E extends Runtype, F extends Runtype, G extends Runtype, H extends Runtype, I extends Runtype, J extends Runtype>( | ||
A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H, I: I, J: J, | ||
): Union10<A, B, C, D, E, F, G, H, I, J> | ||
export function Union(...alternatives: Runtype<any>[]) { | ||
export function Union(...alternatives: Runtype[]): any { | ||
return create(x => { | ||
@@ -138,0 +138,0 @@ for (const { guard } of alternatives) |
@@ -5,4 +5,4 @@ { | ||
"target": "es5", | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"lib": ["es2015"], | ||
"strict": true, | ||
"noUnusedLocals": true, | ||
@@ -9,0 +9,0 @@ "noUnusedParameters": true, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2578
104131
88