Socket
Socket
Sign inDemoInstall

io-ts

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io-ts - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

19

CHANGELOG.md

@@ -15,2 +15,21 @@ # Changelog

# 0.2.0
- **New Feature**
- add `partial` combinator
- add `readonly` combinator
- add `never` type
- **Breaking Changes**
- remove `maybe` combinator, can be defined in userland as
```ts
export function maybe<RT extends t.Any>(type: RT, name?: string): t.UnionType<[RT, typeof t.null], t.TypeOf<RT> | null> {
return t.union([type, t.null], name)
}
```
- **Polish**
- export `pathReporterFailure` function from default reporters
- **Bug Fix**
- revert pruning excess properties
- revert `intersection` combinator accepting only `InterfaceType`s
# 0.1.0

@@ -17,0 +36,0 @@

102

lib-jsnext/index.d.ts

@@ -26,19 +26,6 @@ import { Either } from 'fp-ts/lib/Either';

export declare function validate<T>(value: any, type: Type<T>): Validation<T>;
export declare class LiteralType<T> extends Type<T> {
readonly value: T;
constructor(name: string, validate: Validate<T>, value: T);
}
export declare function literal<T extends string | number | boolean>(value: T): LiteralType<T>;
export declare class KeyofType<D extends {
[key: string]: any;
}> extends Type<keyof D> {
readonly map: D;
constructor(name: string, validate: Validate<keyof D>, map: D);
}
export declare function keyof<D extends {
[key: string]: any;
}>(map: D, name?: string): KeyofType<D>;
declare const nullType: Type<null>;
declare const undefinedType: Type<undefined>;
export declare const any: Type<any>;
export declare const never: Type<never>;
export declare const string: Type<string>;

@@ -60,8 +47,17 @@ export declare const number: Type<number>;

export declare const Integer: RefinementType<Type<number>>;
export declare class LiteralType<T> extends Type<T> {
readonly value: T;
constructor(name: string, validate: Validate<T>, value: T);
}
export declare function literal<T extends string | number | boolean>(value: T): LiteralType<T>;
export declare class KeyofType<D extends {
[key: string]: any;
}> extends Type<keyof D> {
readonly map: D;
constructor(name: string, validate: Validate<keyof D>, map: D);
}
export declare function keyof<D extends {
[key: string]: any;
}>(map: D, name?: string): KeyofType<D>;
export declare function recursion<T>(name: string, definition: (self: Any) => Any): Type<T>;
export declare class MaybeType<RT extends Any> extends Type<TypeOf<RT> | undefined | null> {
readonly type: RT;
constructor(name: string, validate: Validate<TypeOf<RT> | undefined | null>, type: RT);
}
export declare function maybe<RT extends Any>(type: RT, name?: string): MaybeType<RT>;
export declare class ArrayType<RT extends Any> extends Type<Array<TypeOf<RT>>> {

@@ -83,2 +79,13 @@ readonly type: RT;

declare function interfaceType<P extends Props>(props: P, name?: string): InterfaceType<P>;
export declare type PartialOf<P extends Props> = {
[K in keyof P]?: TypeOf<P[K]>;
};
export declare type PartialPropsOf<P extends Props> = {
[K in keyof P]: UnionType<[P[K], Type<undefined>], [TypeOf<P[K]>, undefined]>;
};
export declare class PartialType<P extends Props> extends Type<PartialOf<P>> {
readonly props: PartialPropsOf<P>;
constructor(name: string, validate: Validate<PartialOf<P>>, props: PartialPropsOf<P>);
}
export declare function partial<P extends Props>(props: P, name?: string): PartialType<P>;
export declare class DictionaryType<D extends Type<string>, C extends Any> extends Type<{

@@ -128,28 +135,28 @@ [key: string]: TypeOf<C>;

}
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>, X extends InterfaceType<any>, Y extends InterfaceType<any>, Z extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y> & TypeOf<Z>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>, X extends InterfaceType<any>, Y extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>, X extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H], name?: string): IntersectionType<[A, B, C, D, E, F, G, H], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>>(types: [A, B, C, D, E, F, G], name?: string): IntersectionType<[A, B, C, D, E, F, G], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>>(types: [A, B, C, D, E, F], name?: string): IntersectionType<[A, B, C, D, E, F], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>>(types: [A, B, C, D, E], name?: string): IntersectionType<[A, B, C, D, E], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>>(types: [A, B, C, D], name?: string): IntersectionType<[A, B, C, D], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>>(types: [A, B, C], name?: string): IntersectionType<[A, B, C], TypeOf<A> & TypeOf<B> & TypeOf<C>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>>(types: [A, B], name?: string): IntersectionType<[A, B], TypeOf<A> & TypeOf<B>>;
export declare function intersection<A extends InterfaceType<any>>(types: [A], name?: string): IntersectionType<[A], TypeOf<A>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any, X extends Any, Y extends Any, Z extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y> & TypeOf<Z>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any, X extends Any, Y extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any, X extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any>(types: [A, B, C, D, E, F, G, H, I, J], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any>(types: [A, B, C, D, E, F, G, H, I], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any>(types: [A, B, C, D, E, F, G, H], name?: string): IntersectionType<[A, B, C, D, E, F, G, H], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any>(types: [A, B, C, D, E, F, G], name?: string): IntersectionType<[A, B, C, D, E, F, G], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any>(types: [A, B, C, D, E, F], name?: string): IntersectionType<[A, B, C, D, E, F], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any>(types: [A, B, C, D, E], name?: string): IntersectionType<[A, B, C, D, E], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any>(types: [A, B, C, D], name?: string): IntersectionType<[A, B, C, D], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D>>;
export declare function intersection<A extends Any, B extends Any, C extends Any>(types: [A, B, C], name?: string): IntersectionType<[A, B, C], TypeOf<A> & TypeOf<B> & TypeOf<C>>;
export declare function intersection<A extends Any, B extends Any>(types: [A, B], name?: string): IntersectionType<[A, B], TypeOf<A> & TypeOf<B>>;
export declare function intersection<A extends Any>(types: [A], name?: string): IntersectionType<[A], TypeOf<A>>;
export declare class TupleType<RTS, T> extends Type<T> {

@@ -185,2 +192,7 @@ readonly types: RTS;

export declare function tuple<A extends Any>(types: [A], name?: string): TupleType<[A], [TypeOf<A>]>;
export declare class ReadonlyType<RT extends Any> extends Type<Readonly<TypeOf<RT>>> {
readonly type: RT;
constructor(name: string, validate: Validate<Readonly<TypeOf<RT>>>, type: RT);
}
export declare function readonly<RT extends Any>(type: RT, name?: string): ReadonlyType<RT>;
export { nullType as null, undefinedType as undefined, arrayType as Array, functionType as Function, interfaceType as interface };

@@ -1,6 +0,11 @@

var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {

@@ -43,10 +48,2 @@ for (var s, i = 1, n = arguments.length; i < n; i++) {

}
function hasExcessProps(props, o) {
for (var k in o) {
if (!props.hasOwnProperty(k)) {
return true;
}
}
return false;
}
export function failure(value, context) {

@@ -65,2 +62,30 @@ return new Left([getValidationError(value, context)]);

//
// default types
//
var nullType = new Type('null', function (v, c) { return v === null ? success(v) : failure(v, c); });
var undefinedType = new Type('undefined', function (v, c) { return v === void 0 ? success(v) : failure(v, c); });
export var any = new Type('any', function (v, _) { return success(v); });
export var never = new Type('never', function (v, c) { return failure(v, c); });
export var string = new Type('string', function (v, c) { return typeof v === 'string' ? success(v) : failure(v, c); });
export var number = new Type('number', function (v, c) { return typeof v === 'number' ? success(v) : failure(v, c); });
export var boolean = new Type('boolean', function (v, c) { return typeof v === 'boolean' ? success(v) : failure(v, c); });
var arrayType = new Type('Array', function (v, c) { return Array.isArray(v) ? success(v) : failure(v, c); });
export var Dictionary = new Type('Dictionary', function (v, c) { return v !== null && typeof v === 'object' ? success(v) : failure(v, c); });
var functionType = new Type('Function', function (v, c) { return typeof v === 'function' ? success(v) : failure(v, c); });
var RefinementType = (function (_super) {
__extends(RefinementType, _super);
function RefinementType(name, validate, type, predicate) {
var _this = _super.call(this, name, validate) || this;
_this.type = type;
_this.predicate = predicate;
return _this;
}
return RefinementType;
}(Type));
export { RefinementType };
export function refinement(type, predicate, name) {
return new RefinementType(name || "(" + getTypeName(type) + " | " + getFunctionName(predicate) + ")", function (v, c) { return type.validate(v, c).chain(function (t) { return predicate(t) ? success(t) : failure(v, c); }); }, type, predicate);
}
export var Integer = refinement(number, function (n) { return n % 1 === 0; }, 'Integer');
//
// literal types

@@ -98,32 +123,2 @@ //

//
// default types
//
function isNil(v) {
return v === void 0 || v === null;
}
var nullType = new Type('null', function (v, c) { return v === null ? success(v) : failure(v, c); });
var undefinedType = new Type('undefined', function (v, c) { return v === void 0 ? success(v) : failure(v, c); });
export var any = new Type('any', function (v, _) { return success(v); });
export var string = new Type('string', function (v, c) { return typeof v === 'string' ? success(v) : failure(v, c); });
export var number = new Type('number', function (v, c) { return typeof v === 'number' ? success(v) : failure(v, c); });
export var boolean = new Type('boolean', function (v, c) { return typeof v === 'boolean' ? success(v) : failure(v, c); });
var arrayType = new Type('Array', function (v, c) { return Array.isArray(v) ? success(v) : failure(v, c); });
export var Dictionary = new Type('Dictionary', function (v, c) { return v !== null && typeof v === 'object' ? success(v) : failure(v, c); });
var functionType = new Type('Function', function (v, c) { return typeof v === 'function' ? success(v) : failure(v, c); });
var RefinementType = (function (_super) {
__extends(RefinementType, _super);
function RefinementType(name, validate, type, predicate) {
var _this = _super.call(this, name, validate) || this;
_this.type = type;
_this.predicate = predicate;
return _this;
}
return RefinementType;
}(Type));
export { RefinementType };
export function refinement(type, predicate, name) {
return new RefinementType(name || "(" + getTypeName(type) + " | " + getFunctionName(predicate) + ")", function (v, c) { return type.validate(v, c).chain(function (t) { return predicate(t) ? success(t) : failure(v, c); }); }, type, predicate);
}
export var Integer = refinement(number, function (n) { return n % 1 === 0; }, 'Integer');
//
// recursive types

@@ -138,18 +133,2 @@ //

//
// maybes
//
var MaybeType = (function (_super) {
__extends(MaybeType, _super);
function MaybeType(name, validate, type) {
var _this = _super.call(this, name, validate) || this;
_this.type = type;
return _this;
}
return MaybeType;
}(Type));
export { MaybeType };
export function maybe(type, name) {
return new MaybeType(name || "?" + getTypeName(type), function (v, c) { return isNil(v) ? success(v) : type.validate(v, c); }, type);
}
//
// arrays

@@ -198,3 +177,3 @@ //

return new InterfaceType(name || "{ " + Object.keys(props).map(function (k) { return k + ": " + props[k].name; }).join(', ') + " }", function (v, c) { return Dictionary.validate(v, c).chain(function (o) {
var t = {};
var t = __assign({}, o);
var errors = [];

@@ -214,8 +193,23 @@ var changed = false;

}
if (!changed) {
changed = hasExcessProps(props, o);
}
return errors.length ? new Left(errors) : success((changed ? t : o));
}); }, props);
}
var PartialType = (function (_super) {
__extends(PartialType, _super);
function PartialType(name, validate, props) {
var _this = _super.call(this, name, validate) || this;
_this.props = props;
return _this;
}
return PartialType;
}(Type));
export { PartialType };
export function partial(props, name) {
var partials = {};
for (var k in props) {
partials[k] = union([props[k], undefinedType]);
}
var type = interfaceType(partials);
return new PartialType(name || type.name, function (v, c) { return type.validate(v, c); }, partials);
}
//

@@ -297,6 +291,16 @@ // dictionaries

export function intersection(types, name) {
var displayName = name || "(" + types.map(getTypeName).join(' & ') + ")";
var props = types.reduce(function (acc, x) { return (__assign({}, acc, x.props)); }, {});
var type = interfaceType(props, displayName);
return new IntersectionType(displayName, type.validate, types);
return new IntersectionType(name || "(" + types.map(getTypeName).join(' & ') + ")", function (v, c) {
var t = v;
var changed = false;
var errors = [];
for (var i = 0, len = types.length; i < len; i++) {
var type = types[i];
var validation = type.validate(t, c);
validation.fold(function (error) { return pushAll(errors, error); }, function (vv) {
changed = changed || (vv !== t);
t = vv;
});
}
return errors.length ? new Left(errors) : success(changed ? t : v);
}, types);
}

@@ -336,3 +340,21 @@ //

}
var ReadonlyType = (function (_super) {
__extends(ReadonlyType, _super);
function ReadonlyType(name, validate, type) {
var _this = _super.call(this, name, validate) || this;
_this.type = type;
return _this;
}
return ReadonlyType;
}(Type));
export { ReadonlyType };
export function readonly(type, name) {
return new ReadonlyType(name || "Readonly<" + getTypeName(type) + ">", function (v, c) { return type.validate(v, c).map(function (x) {
if (process.env.NODE_ENV !== 'production') {
return Object.freeze(x);
}
return x;
}); }, type);
}
export { nullType as null, undefinedType as undefined, arrayType as Array, functionType as Function, interfaceType as interface };
//# sourceMappingURL=index.js.map
import { Reporter } from './Reporter';
import { ValidationError } from '../index';
export declare function pathReporterFailure(es: Array<ValidationError>): Array<string>;
export declare const PathReporter: Reporter<Array<string>>;
export declare const ThrowReporter: Reporter<void>;

@@ -12,4 +12,10 @@ import { isLeft } from 'fp-ts/lib/Either';

}
function getMessage(value, context) {
return "Invalid value " + stringify(value) + " supplied to " + getContextPath(context);
}
export function pathReporterFailure(es) {
return es.map(function (e) { return getMessage(e.value, e.context); });
}
export var PathReporter = {
report: function (validation) { return validation.fold(function (es) { return es.map(function (e) { return "Invalid value " + stringify(e.value) + " supplied to " + getContextPath(e.context); }); }, function () { return ['No errors!']; }); }
report: function (validation) { return validation.fold(pathReporterFailure, function () { return ['No errors!']; }); }
};

@@ -16,0 +22,0 @@ export var ThrowReporter = {

@@ -26,19 +26,6 @@ import { Either } from 'fp-ts/lib/Either';

export declare function validate<T>(value: any, type: Type<T>): Validation<T>;
export declare class LiteralType<T> extends Type<T> {
readonly value: T;
constructor(name: string, validate: Validate<T>, value: T);
}
export declare function literal<T extends string | number | boolean>(value: T): LiteralType<T>;
export declare class KeyofType<D extends {
[key: string]: any;
}> extends Type<keyof D> {
readonly map: D;
constructor(name: string, validate: Validate<keyof D>, map: D);
}
export declare function keyof<D extends {
[key: string]: any;
}>(map: D, name?: string): KeyofType<D>;
declare const nullType: Type<null>;
declare const undefinedType: Type<undefined>;
export declare const any: Type<any>;
export declare const never: Type<never>;
export declare const string: Type<string>;

@@ -60,8 +47,17 @@ export declare const number: Type<number>;

export declare const Integer: RefinementType<Type<number>>;
export declare class LiteralType<T> extends Type<T> {
readonly value: T;
constructor(name: string, validate: Validate<T>, value: T);
}
export declare function literal<T extends string | number | boolean>(value: T): LiteralType<T>;
export declare class KeyofType<D extends {
[key: string]: any;
}> extends Type<keyof D> {
readonly map: D;
constructor(name: string, validate: Validate<keyof D>, map: D);
}
export declare function keyof<D extends {
[key: string]: any;
}>(map: D, name?: string): KeyofType<D>;
export declare function recursion<T>(name: string, definition: (self: Any) => Any): Type<T>;
export declare class MaybeType<RT extends Any> extends Type<TypeOf<RT> | undefined | null> {
readonly type: RT;
constructor(name: string, validate: Validate<TypeOf<RT> | undefined | null>, type: RT);
}
export declare function maybe<RT extends Any>(type: RT, name?: string): MaybeType<RT>;
export declare class ArrayType<RT extends Any> extends Type<Array<TypeOf<RT>>> {

@@ -83,2 +79,13 @@ readonly type: RT;

declare function interfaceType<P extends Props>(props: P, name?: string): InterfaceType<P>;
export declare type PartialOf<P extends Props> = {
[K in keyof P]?: TypeOf<P[K]>;
};
export declare type PartialPropsOf<P extends Props> = {
[K in keyof P]: UnionType<[P[K], Type<undefined>], [TypeOf<P[K]>, undefined]>;
};
export declare class PartialType<P extends Props> extends Type<PartialOf<P>> {
readonly props: PartialPropsOf<P>;
constructor(name: string, validate: Validate<PartialOf<P>>, props: PartialPropsOf<P>);
}
export declare function partial<P extends Props>(props: P, name?: string): PartialType<P>;
export declare class DictionaryType<D extends Type<string>, C extends Any> extends Type<{

@@ -128,28 +135,28 @@ [key: string]: TypeOf<C>;

}
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>, X extends InterfaceType<any>, Y extends InterfaceType<any>, Z extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y> & TypeOf<Z>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>, X extends InterfaceType<any>, Y extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>, X extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>, W extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>, V extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>, U extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>, T extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>, S extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>, R extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>, Q extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>, P extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>, O extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>, N extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>, M extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>, L extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K, L], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>, K extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J, K], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>, J extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I, J], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>, I extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H, I], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>, H extends InterfaceType<any>>(types: [A, B, C, D, E, F, G, H], name?: string): IntersectionType<[A, B, C, D, E, F, G, H], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>, G extends InterfaceType<any>>(types: [A, B, C, D, E, F, G], name?: string): IntersectionType<[A, B, C, D, E, F, G], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>, F extends InterfaceType<any>>(types: [A, B, C, D, E, F], name?: string): IntersectionType<[A, B, C, D, E, F], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>, E extends InterfaceType<any>>(types: [A, B, C, D, E], name?: string): IntersectionType<[A, B, C, D, E], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>, D extends InterfaceType<any>>(types: [A, B, C, D], name?: string): IntersectionType<[A, B, C, D], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>, C extends InterfaceType<any>>(types: [A, B, C], name?: string): IntersectionType<[A, B, C], TypeOf<A> & TypeOf<B> & TypeOf<C>>;
export declare function intersection<A extends InterfaceType<any>, B extends InterfaceType<any>>(types: [A, B], name?: string): IntersectionType<[A, B], TypeOf<A> & TypeOf<B>>;
export declare function intersection<A extends InterfaceType<any>>(types: [A], name?: string): IntersectionType<[A], TypeOf<A>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any, X extends Any, Y extends Any, Z extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y> & TypeOf<Z>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any, X extends Any, Y extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X> & TypeOf<Y>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any, X extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W> & TypeOf<X>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any, W extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V> & TypeOf<W>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any, V extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U> & TypeOf<V>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any, U extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T> & TypeOf<U>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any, T extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S> & TypeOf<T>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any, S extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R> & TypeOf<S>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any, R extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q> & TypeOf<R>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any, Q extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P> & TypeOf<Q>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any, P extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O> & TypeOf<P>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any, O extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N, O], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N> & TypeOf<O>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any, N extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M, N], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M, N], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M> & TypeOf<N>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any, M extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L, M], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L, M], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L> & TypeOf<M>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any, L extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K, L], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K, L], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K> & TypeOf<L>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any, K extends Any>(types: [A, B, C, D, E, F, G, H, I, J, K], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J, K], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J> & TypeOf<K>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any, J extends Any>(types: [A, B, C, D, E, F, G, H, I, J], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I, J], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I> & TypeOf<J>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any, I extends Any>(types: [A, B, C, D, E, F, G, H, I], name?: string): IntersectionType<[A, B, C, D, E, F, G, H, I], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H> & TypeOf<I>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any, H extends Any>(types: [A, B, C, D, E, F, G, H], name?: string): IntersectionType<[A, B, C, D, E, F, G, H], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G> & TypeOf<H>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any, G extends Any>(types: [A, B, C, D, E, F, G], name?: string): IntersectionType<[A, B, C, D, E, F, G], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F> & TypeOf<G>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any, F extends Any>(types: [A, B, C, D, E, F], name?: string): IntersectionType<[A, B, C, D, E, F], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E> & TypeOf<F>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any, E extends Any>(types: [A, B, C, D, E], name?: string): IntersectionType<[A, B, C, D, E], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D> & TypeOf<E>>;
export declare function intersection<A extends Any, B extends Any, C extends Any, D extends Any>(types: [A, B, C, D], name?: string): IntersectionType<[A, B, C, D], TypeOf<A> & TypeOf<B> & TypeOf<C> & TypeOf<D>>;
export declare function intersection<A extends Any, B extends Any, C extends Any>(types: [A, B, C], name?: string): IntersectionType<[A, B, C], TypeOf<A> & TypeOf<B> & TypeOf<C>>;
export declare function intersection<A extends Any, B extends Any>(types: [A, B], name?: string): IntersectionType<[A, B], TypeOf<A> & TypeOf<B>>;
export declare function intersection<A extends Any>(types: [A], name?: string): IntersectionType<[A], TypeOf<A>>;
export declare class TupleType<RTS, T> extends Type<T> {

@@ -185,2 +192,7 @@ readonly types: RTS;

export declare function tuple<A extends Any>(types: [A], name?: string): TupleType<[A], [TypeOf<A>]>;
export declare class ReadonlyType<RT extends Any> extends Type<Readonly<TypeOf<RT>>> {
readonly type: RT;
constructor(name: string, validate: Validate<Readonly<TypeOf<RT>>>, type: RT);
}
export declare function readonly<RT extends Any>(type: RT, name?: string): ReadonlyType<RT>;
export { nullType as null, undefinedType as undefined, arrayType as Array, functionType as Function, interfaceType as interface };
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {

@@ -15,2 +20,3 @@ for (var s, i = 1, n = arguments.length; i < n; i++) {

};
Object.defineProperty(exports, "__esModule", { value: true });
var Either_1 = require("fp-ts/lib/Either");

@@ -46,10 +52,2 @@ ;

}
function hasExcessProps(props, o) {
for (var k in o) {
if (!props.hasOwnProperty(k)) {
return true;
}
}
return false;
}
function failure(value, context) {

@@ -71,2 +69,35 @@ return new Either_1.Left([getValidationError(value, context)]);

//
// default types
//
var nullType = new Type('null', function (v, c) { return v === null ? success(v) : failure(v, c); });
exports.null = nullType;
var undefinedType = new Type('undefined', function (v, c) { return v === void 0 ? success(v) : failure(v, c); });
exports.undefined = undefinedType;
exports.any = new Type('any', function (v, _) { return success(v); });
exports.never = new Type('never', function (v, c) { return failure(v, c); });
exports.string = new Type('string', function (v, c) { return typeof v === 'string' ? success(v) : failure(v, c); });
exports.number = new Type('number', function (v, c) { return typeof v === 'number' ? success(v) : failure(v, c); });
exports.boolean = new Type('boolean', function (v, c) { return typeof v === 'boolean' ? success(v) : failure(v, c); });
var arrayType = new Type('Array', function (v, c) { return Array.isArray(v) ? success(v) : failure(v, c); });
exports.Array = arrayType;
exports.Dictionary = new Type('Dictionary', function (v, c) { return v !== null && typeof v === 'object' ? success(v) : failure(v, c); });
var functionType = new Type('Function', function (v, c) { return typeof v === 'function' ? success(v) : failure(v, c); });
exports.Function = functionType;
var RefinementType = (function (_super) {
__extends(RefinementType, _super);
function RefinementType(name, validate, type, predicate) {
var _this = _super.call(this, name, validate) || this;
_this.type = type;
_this.predicate = predicate;
return _this;
}
return RefinementType;
}(Type));
exports.RefinementType = RefinementType;
function refinement(type, predicate, name) {
return new RefinementType(name || "(" + getTypeName(type) + " | " + getFunctionName(predicate) + ")", function (v, c) { return type.validate(v, c).chain(function (t) { return predicate(t) ? success(t) : failure(v, c); }); }, type, predicate);
}
exports.refinement = refinement;
exports.Integer = refinement(exports.number, function (n) { return n % 1 === 0; }, 'Integer');
//
// literal types

@@ -106,37 +137,2 @@ //

//
// default types
//
function isNil(v) {
return v === void 0 || v === null;
}
var nullType = new Type('null', function (v, c) { return v === null ? success(v) : failure(v, c); });
exports.null = nullType;
var undefinedType = new Type('undefined', function (v, c) { return v === void 0 ? success(v) : failure(v, c); });
exports.undefined = undefinedType;
exports.any = new Type('any', function (v, _) { return success(v); });
exports.string = new Type('string', function (v, c) { return typeof v === 'string' ? success(v) : failure(v, c); });
exports.number = new Type('number', function (v, c) { return typeof v === 'number' ? success(v) : failure(v, c); });
exports.boolean = new Type('boolean', function (v, c) { return typeof v === 'boolean' ? success(v) : failure(v, c); });
var arrayType = new Type('Array', function (v, c) { return Array.isArray(v) ? success(v) : failure(v, c); });
exports.Array = arrayType;
exports.Dictionary = new Type('Dictionary', function (v, c) { return v !== null && typeof v === 'object' ? success(v) : failure(v, c); });
var functionType = new Type('Function', function (v, c) { return typeof v === 'function' ? success(v) : failure(v, c); });
exports.Function = functionType;
var RefinementType = (function (_super) {
__extends(RefinementType, _super);
function RefinementType(name, validate, type, predicate) {
var _this = _super.call(this, name, validate) || this;
_this.type = type;
_this.predicate = predicate;
return _this;
}
return RefinementType;
}(Type));
exports.RefinementType = RefinementType;
function refinement(type, predicate, name) {
return new RefinementType(name || "(" + getTypeName(type) + " | " + getFunctionName(predicate) + ")", function (v, c) { return type.validate(v, c).chain(function (t) { return predicate(t) ? success(t) : failure(v, c); }); }, type, predicate);
}
exports.refinement = refinement;
exports.Integer = refinement(exports.number, function (n) { return n % 1 === 0; }, 'Integer');
//
// recursive types

@@ -152,19 +148,2 @@ //

//
// maybes
//
var MaybeType = (function (_super) {
__extends(MaybeType, _super);
function MaybeType(name, validate, type) {
var _this = _super.call(this, name, validate) || this;
_this.type = type;
return _this;
}
return MaybeType;
}(Type));
exports.MaybeType = MaybeType;
function maybe(type, name) {
return new MaybeType(name || "?" + getTypeName(type), function (v, c) { return isNil(v) ? success(v) : type.validate(v, c); }, type);
}
exports.maybe = maybe;
//
// arrays

@@ -214,3 +193,3 @@ //

return new InterfaceType(name || "{ " + Object.keys(props).map(function (k) { return k + ": " + props[k].name; }).join(', ') + " }", function (v, c) { return exports.Dictionary.validate(v, c).chain(function (o) {
var t = {};
var t = __assign({}, o);
var errors = [];

@@ -230,5 +209,2 @@ var changed = false;

}
if (!changed) {
changed = hasExcessProps(props, o);
}
return errors.length ? new Either_1.Left(errors) : success((changed ? t : o));

@@ -238,2 +214,21 @@ }); }, props);

exports.interface = interfaceType;
var PartialType = (function (_super) {
__extends(PartialType, _super);
function PartialType(name, validate, props) {
var _this = _super.call(this, name, validate) || this;
_this.props = props;
return _this;
}
return PartialType;
}(Type));
exports.PartialType = PartialType;
function partial(props, name) {
var partials = {};
for (var k in props) {
partials[k] = union([props[k], undefinedType]);
}
var type = interfaceType(partials);
return new PartialType(name || type.name, function (v, c) { return type.validate(v, c); }, partials);
}
exports.partial = partial;
//

@@ -317,6 +312,16 @@ // dictionaries

function intersection(types, name) {
var displayName = name || "(" + types.map(getTypeName).join(' & ') + ")";
var props = types.reduce(function (acc, x) { return (__assign({}, acc, x.props)); }, {});
var type = interfaceType(props, displayName);
return new IntersectionType(displayName, type.validate, types);
return new IntersectionType(name || "(" + types.map(getTypeName).join(' & ') + ")", function (v, c) {
var t = v;
var changed = false;
var errors = [];
for (var i = 0, len = types.length; i < len; i++) {
var type = types[i];
var validation = type.validate(t, c);
validation.fold(function (error) { return pushAll(errors, error); }, function (vv) {
changed = changed || (vv !== t);
t = vv;
});
}
return errors.length ? new Either_1.Left(errors) : success(changed ? t : v);
}, types);
}

@@ -358,2 +363,21 @@ exports.intersection = intersection;

exports.tuple = tuple;
var ReadonlyType = (function (_super) {
__extends(ReadonlyType, _super);
function ReadonlyType(name, validate, type) {
var _this = _super.call(this, name, validate) || this;
_this.type = type;
return _this;
}
return ReadonlyType;
}(Type));
exports.ReadonlyType = ReadonlyType;
function readonly(type, name) {
return new ReadonlyType(name || "Readonly<" + getTypeName(type) + ">", function (v, c) { return type.validate(v, c).map(function (x) {
if (process.env.NODE_ENV !== 'production') {
return Object.freeze(x);
}
return x;
}); }, type);
}
exports.readonly = readonly;
//# sourceMappingURL=index.js.map
import { Reporter } from './Reporter';
import { ValidationError } from '../index';
export declare function pathReporterFailure(es: Array<ValidationError>): Array<string>;
export declare const PathReporter: Reporter<Array<string>>;
export declare const ThrowReporter: Reporter<void>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Either_1 = require("fp-ts/lib/Either");

@@ -13,4 +14,11 @@ var index_1 = require("../index");

}
function getMessage(value, context) {
return "Invalid value " + stringify(value) + " supplied to " + getContextPath(context);
}
function pathReporterFailure(es) {
return es.map(function (e) { return getMessage(e.value, e.context); });
}
exports.pathReporterFailure = pathReporterFailure;
exports.PathReporter = {
report: function (validation) { return validation.fold(function (es) { return es.map(function (e) { return "Invalid value " + stringify(e.value) + " supplied to " + getContextPath(e.context); }); }, function () { return ['No errors!']; }); }
report: function (validation) { return validation.fold(pathReporterFailure, function () { return ['No errors!']; }); }
};

@@ -17,0 +25,0 @@ exports.ThrowReporter = {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=Reporter.js.map
{
"name": "io-ts",
"version": "0.1.1",
"version": "0.2.0",
"description": "TypeScript compatible runtime type system for IO validation",

@@ -13,3 +13,5 @@ "files": [

"scripts": {
"test": "mocha -r ts-node/register test/*.ts",
"typings-checker": "typings-checker --allow-expect-error --project typings-checker/tsconfig.json typings-checker/index.ts",
"mocha": "mocha -r ts-node/register test/*.ts",
"test": "npm run typings-checker && npm run mocha",
"build": "rm -rf lib/* && rm -rf lib-jsnext/* && tsc && tsc -m es6 --outDir lib-jsnext"

@@ -35,3 +37,4 @@ },

"ts-node": "^2.0.0",
"typescript": "^2.2.0"
"typescript": "^2.2.0",
"typings-checker": "^1.1.2"
},

@@ -38,0 +41,0 @@ "tags": [

@@ -65,3 +65,3 @@ # The idea

```js
import { PathReporter, ThrowReporter } from '../src/reporters/default'
import { PathReporter, ThrowReporter } from 'io-ts/reporters/default'

@@ -128,4 +128,6 @@ const validation = t.validate({"name":"Giulio"}, Person)

| number | `number` | `t.number` |
| boolean | `boolean` | `t.boolean` |
| any | `any` | `t.any` |
| never | `never` | `t.never` |
| integer | ✘ | `t.Integer` |
| boolean | `boolean` | `t.boolean` |
| generic array | `Array<any>` | `t.Array` |

@@ -137,3 +139,5 @@ | generic dictionary | `{ [key: string]: any }` | `t.Dictionary` |

| literal | `'s'` | `t.literal('s')` |
| maybe | `A | undefined | null` | `t.maybe(A)` |
| maybe | `A | null` | `t.maybe(A)` |
| partial | `Partial<{ name: string }>` | `t.partial({ name: t.string })` |
| readonly | `Readonly<{ name: string }>` | `t.readonly({ name: t.string })` |
| dictionaries | `{ [key: A]: B }` | `t.dictionary(A, B)` |

@@ -148,2 +152,46 @@ | refinement | ✘ | `t.refinement(A, predicate)` |

# Custom types
You can define your own types. Let's see some examples
```ts
import * as t from 'io-ts'
import { pathReporterFailure } from 'io-ts/lib/reporters/default'
// return a Date from an ISO string
const ISODate = new t.Type<Date>(
'ISODate',
(v, c) => t.string.validate(v, c).chain(s => {
const d = new Date(s)
return isNaN(d.getTime()) ? t.failure<Date>(s, c) : t.success(d)
})
)
const s = new Date(1973, 10, 30).toISOString()
t.validate(s, ISODate).fold(pathReporterFailure, x => [String(x)])
// => [ 'Fri Nov 30 1973 00:00:00 GMT+0100 (CET)' ]
t.validate('foo', ISODate).fold(pathReporterFailure, x => [String(x)])
// => [ 'Invalid value "foo" supplied to : ISODate' ]
```
# Custom combinators
You can define your own combinators. Let's see some examples
## The `maybe` combinator
```ts
export function maybe<RT extends t.Any>(type: RT, name?: string): t.UnionType<[RT, typeof t.null], t.TypeOf<RT> | null> {
return t.union([type, t.null], name)
}
```
## The `brand` combinator
```ts
export function brand<T, B extends string>(type: t.Type<T>, brand: B): t.Type<T & { readonly __brand: B }> {
return type as any
}
```
# Known issues

@@ -150,0 +198,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc