io-ts

  • Version 2.2.22
  • Published
  • 460 kB
  • No dependencies
  • MIT license

Install

npm i io-ts
yarn add io-ts
pnpm add io-ts

Overview

TypeScript runtime type system for IO decoding/encoding

Index

Variables

Functions

Classes

Interfaces

Type Aliases

Variables

variable any

const any: AnyC;
  • primitives 1.0.0

variable Array

const Array: UnknownArrayC;
  • primitives 1.7.1

variable bigint

const bigint: BigIntC;
  • primitives 2.1.0

variable boolean

const boolean: BooleanC;
  • primitives 1.0.0

variable dictionary

const dictionary: <D extends Mixed, C extends Mixed>(
domain: D,
codomain: C,
name?: string
) => RecordC<D, C>;
  • Use record instead.

    combinators 1.0.0

    Deprecated

variable Dictionary

const Dictionary: UnknownRecordC;
  • Use UnknownRecord instead.

    primitives 1.0.0

    Deprecated

variable Function

const Function: FunctionC;
  • primitives 1.0.0

variable Int

const Int: BrandC<NumberC, IntBrand>;
  • A branded codec representing an integer

    primitives 1.8.1

variable Integer

const Integer: RefinementC<NumberC, number>;
  • primitives 1.0.0

variable never

const never: NeverC;
  • primitives 1.0.0

variable null

const null: NullC
  • primitives 1.0.0

variable nullType

const nullType: NullC;
  • primitives 1.0.0

variable number

const number: NumberC;
  • primitives 1.0.0

variable object

const object: ObjectC;
  • Use UnknownRecord instead.

    primitives 1.0.0

    Deprecated

variable string

const string: StringC;
  • primitives 1.0.0

variable undefined

const undefined: UndefinedC;

    variable unknown

    const unknown: UnknownC;
    • primitives 1.5.0

    variable UnknownArray

    const UnknownArray: UnknownArrayC;
    • primitives 1.7.1

    variable UnknownRecord

    const UnknownRecord: UnknownRecordC;
    • primitives 1.7.1

    variable void

    const void: VoidC
    • primitives 1.2.0

    variable voidType

    const voidType: VoidC;
    • primitives 1.2.0

    Functions

    function alias

    alias: {
    <A, O, P, I>(codec: PartialType<P, A, O, I>): <
    AA extends A,
    OO extends O = O,
    PP extends P = P,
    II extends I = I
    >() => PartialType<PP, AA, OO, II>;
    <A, O, P, I>(codec: StrictType<P, A, O, I>): <
    AA extends A,
    OO extends O = O,
    PP extends P = P,
    II extends I = I
    >() => StrictType<PP, AA, OO, II>;
    <A, O, P, I>(codec: InterfaceType<P, A, O, I>): <
    AA extends A,
    OO extends O = O,
    PP extends P = P,
    II extends I = I
    >() => InterfaceType<PP, AA, OO, II>;
    };
    • Keeps the codec "kind".

      combinators 1.1.0

      Deprecated

    function appendContext

    appendContext: (
    c: Context,
    key: string,
    decoder: Decoder<any, any>,
    actual?: unknown
    ) => Context;
    • 1.0.0

    function array

    array: <C extends Mixed>(item: C, name?: string) => ArrayC<C>;
    • combinators 1.0.0

    function brand

    brand: <
    C extends Any,
    N extends string,
    B extends { readonly [K in N]: symbol }
    >(
    codec: C,
    predicate: Refinement<TypeOf<C>, Branded<TypeOf<C>, B>>,
    name: N
    ) => BrandC<C, B>;
    • combinators 1.8.1

    function clean

    clean: <A, O = A, I = unknown>(codec: Type<A, O, I>) => Type<A, O, I>;
    • Drops the codec "kind".

      combinators 1.1.0

      Deprecated

    function exact

    exact: <C extends HasProps>(codec: C, name?: string) => ExactC<C>;
    • Strips additional properties.

      combinators 1.1.0

    function failure

    failure: <T>(
    value: unknown,
    context: Context,
    message?: string
    ) => Either<Errors, A>;
    • Decode error 1.0.0

    function failures

    failures: <T>(errors: Errors) => Either<Errors, A>;
    • Decode error 1.0.0

    function getContextEntry

    getContextEntry: (key: string, decoder: Decoder<any, any>) => ContextEntry;
    • 1.0.0

    function getDefaultContext

    getDefaultContext: (decoder: Decoder<any, any>) => Context;
    • 1.0.0

      Deprecated

    function getFunctionName

    getFunctionName: (f: Function) => string;
    • 1.0.0

    function getValidationError

    getValidationError: (value: unknown, context: Context) => ValidationError;
    • 1.0.0

      Deprecated

    function identity

    identity: <A>(a: A) => A;
    • 1.0.0

    function interface

    interface: <P extends Props>(props: P, name?: string) => TypeC<P>;
    • combinators 1.0.0

    function intersection

    intersection: {
    <
    A extends Mixed,
    B extends Mixed,
    C extends Mixed,
    D extends Mixed,
    E extends Mixed
    >(
    codecs: [A, B, C, D, E],
    name?: string
    ): IntersectionC<[A, B, C, D, E]>;
    <A extends Mixed, B extends Mixed, C extends Mixed, D extends Mixed>(
    codecs: [A, B, C, D],
    name?: string
    ): IntersectionC<[A, B, C, D]>;
    <A extends Mixed, B extends Mixed, C extends Mixed>(
    codecs: [A, B, C],
    name?: string
    ): IntersectionC<[A, B, C]>;
    <A extends Mixed, B extends Mixed>(codecs: [A, B], name?: string): IntersectionC<
    [A, B]
    >;
    };
    • combinators 1.0.0

    function keyof

    keyof: <D extends { [key: string]: unknown }>(
    keys: D,
    name?: string
    ) => KeyofC<D>;
    • constructors 1.0.0

    function literal

    literal: <V extends LiteralValue>(value: V, name?: string) => LiteralC<V>;
    • constructors 1.0.0

    function partial

    partial: <P extends Props>(props: P, name?: string) => PartialC<P>;
    • combinators 1.0.0

    function readonly

    readonly: <C extends Mixed>(codec: C, name?: string) => ReadonlyC<C>;
    • combinators 1.0.0

    function readonlyArray

    readonlyArray: <C extends Mixed>(item: C, name?: string) => ReadonlyArrayC<C>;
    • combinators 1.0.0

    function record

    record: <D extends Mixed, C extends Mixed>(
    domain: D,
    codomain: C,
    name?: string
    ) => RecordC<D, C>;
    • combinators 1.7.1

    function recursion

    recursion: <A, O = A, I = unknown, C extends Type<A, O, I> = Type<A, O, I>>(
    name: string,
    definition: (self: C) => C
    ) => RecursiveType<C, A, O, I>;
    • combinators 1.0.0

    function refinement

    refinement: {
    <C extends Any, B extends TypeOf<C>>(
    codec: C,
    refinement: Refinement<TypeOf<C>, B>,
    name?: string
    ): RefinementC<C, B>;
    <C extends Any>(
    codec: C,
    predicate: Predicate<TypeOf<C>>,
    name?: string
    ): RefinementC<C, TypeOf<C>>;
    };
    • combinators 1.0.0

    function strict

    strict: <P extends Props>(props: P, name?: string) => ExactC<TypeC<P>>;
    • Strips additional properties, equivalent to exact(type(props)).

      combinators 1.0.0

    function success

    success: <T>(value: T) => Either<Errors, A>;
    • Decode error 1.0.0

    function taggedUnion

    taggedUnion: <Tag extends string, CS extends [Mixed, Mixed, ...Mixed[]]>(
    tag: Tag,
    codecs: CS,
    name?: string
    ) => TaggedUnionC<Tag, CS>;
    • Use union instead.

      combinators 1.3.0

      Deprecated

    function tuple

    tuple: {
    <
    A extends Mixed,
    B extends Mixed,
    C extends Mixed,
    D extends Mixed,
    E extends Mixed
    >(
    codecs: [A, B, C, D, E],
    name?: string
    ): TupleC<[A, B, C, D, E]>;
    <A extends Mixed, B extends Mixed, C extends Mixed, D extends Mixed>(
    codecs: [A, B, C, D],
    name?: string
    ): TupleC<[A, B, C, D]>;
    <A extends Mixed, B extends Mixed, C extends Mixed>(
    codecs: [A, B, C],
    name?: string
    ): TupleC<[A, B, C]>;
    <A extends Mixed, B extends Mixed>(codecs: [A, B], name?: string): TupleC<
    [A, B]
    >;
    <A extends Mixed>(codecs: [A], name?: string): TupleC<[A]>;
    };
    • combinators 1.0.0

    function type

    type: <P extends Props>(props: P, name?: string) => TypeC<P>;
    • combinators 1.0.0

    function union

    union: <CS extends [Mixed, Mixed, ...Mixed[]]>(
    codecs: CS,
    name?: string
    ) => UnionC<CS>;
    • combinators 1.0.0

    Classes

    class AnyArrayType

    class AnyArrayType extends Type<Array<unknown>> {}
    • 1.0.0

    constructor

    constructor();

      class AnyDictionaryType

      class AnyDictionaryType extends Type<{
      [key: string]: unknown;
      }> {}
      • 1.0.0

      constructor

      constructor();

        class AnyType

        class AnyType extends Type<any> {}
        • 1.0.0

        constructor

        constructor();

          class ArrayType

          class ArrayType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {}
          • 1.0.0

          constructor

          constructor(
          name: string,
          is: Is<A>,
          validate: Validate<I, A>,
          encode: Encode<A, O>,
          type: Any
          );

            property type

            readonly type: Any;

              class BigIntType

              class BigIntType extends Type<bigint> {}
              • 2.1.0

              constructor

              constructor();

                class BooleanType

                class BooleanType extends Type<boolean> {}
                • 1.0.0

                constructor

                constructor();

                  class DictionaryType

                  class DictionaryType<
                  D extends Any,
                  C extends Any,
                  A = any,
                  O = A,
                  I = unknown
                  > extends Type<A, O, I> {}
                  • 1.0.0

                  constructor

                  constructor(
                  name: string,
                  is: Is<A>,
                  validate: Validate<I, A>,
                  encode: Encode<A, O>,
                  domain: Any,
                  codomain: Any
                  );

                    property codomain

                    readonly codomain: Any;

                      property domain

                      readonly domain: Any;

                        class ExactType

                        class ExactType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {}
                        • 1.1.0

                        constructor

                        constructor(
                        name: string,
                        is: Is<A>,
                        validate: Validate<I, A>,
                        encode: Encode<A, O>,
                        type: Any
                        );

                          property type

                          readonly type: Any;

                            class FunctionType

                            class FunctionType extends Type<Function> {}
                            • 1.0.0

                            constructor

                            constructor();

                              class InterfaceType

                              class InterfaceType<P, A = any, O = A, I = unknown> extends Type<A, O, I> {}
                              • 1.0.0

                              constructor

                              constructor(
                              name: string,
                              is: Is<A>,
                              validate: Validate<I, A>,
                              encode: Encode<A, O>,
                              props: {}
                              );

                                property props

                                readonly props: {};

                                  class IntersectionType

                                  class IntersectionType<
                                  CS extends Array<Any>,
                                  A = any,
                                  O = A,
                                  I = unknown
                                  > extends Type<A, O, I> {}
                                  • 1.0.0

                                  constructor

                                  constructor(
                                  name: string,
                                  is: Is<A>,
                                  validate: Validate<I, A>,
                                  encode: Encode<A, O>,
                                  types: Any[]
                                  );

                                    property types

                                    readonly types: Any[];

                                      class KeyofType

                                      class KeyofType<
                                      D extends {
                                      [key: string]: unknown;
                                      }
                                      > extends Type<keyof D> {}
                                      • 1.0.0

                                      constructor

                                      constructor(
                                      name: string,
                                      is: Is<keyof D>,
                                      validate: Validate<unknown, keyof D>,
                                      encode: Encode<keyof D, keyof D>,
                                      keys: { [key: string]: unknown }
                                      );

                                        property keys

                                        readonly keys: { [key: string]: unknown };

                                          class LiteralType

                                          class LiteralType<V extends LiteralValue> extends Type<V> {}
                                          • 1.0.0

                                          constructor

                                          constructor(
                                          name: string,
                                          is: Is<V>,
                                          validate: Validate<unknown, V>,
                                          encode: Encode<V, V>,
                                          value: LiteralValue
                                          );

                                            property value

                                            readonly value: LiteralValue;

                                              class NeverType

                                              class NeverType extends Type<never> {}
                                              • 1.0.0

                                              constructor

                                              constructor();

                                                class NullType

                                                class NullType extends Type<null> {}
                                                • 1.0.0

                                                constructor

                                                constructor();

                                                  class NumberType

                                                  class NumberType extends Type<number> {}
                                                  • 1.0.0

                                                  constructor

                                                  constructor();

                                                    class ObjectType

                                                    class ObjectType extends Type<object> {}
                                                    • 1.0.0

                                                      Deprecated

                                                    constructor

                                                    constructor();

                                                      class PartialType

                                                      class PartialType<P, A = any, O = A, I = unknown> extends Type<A, O, I> {}
                                                      • 1.0.0

                                                      constructor

                                                      constructor(
                                                      name: string,
                                                      is: Is<A>,
                                                      validate: Validate<I, A>,
                                                      encode: Encode<A, O>,
                                                      props: {}
                                                      );

                                                        property props

                                                        readonly props: {};

                                                          class ReadonlyArrayType

                                                          class ReadonlyArrayType<C extends Any, A = any, O = A, I = unknown> extends Type<
                                                          A,
                                                          O,
                                                          I
                                                          > {}
                                                          • 1.0.0

                                                          constructor

                                                          constructor(
                                                          name: string,
                                                          is: Is<A>,
                                                          validate: Validate<I, A>,
                                                          encode: Encode<A, O>,
                                                          type: Any
                                                          );

                                                            property type

                                                            readonly type: Any;

                                                              class ReadonlyType

                                                              class ReadonlyType<C extends Any, A = any, O = A, I = unknown> extends Type<
                                                              A,
                                                              O,
                                                              I
                                                              > {}
                                                              • 1.0.0

                                                              constructor

                                                              constructor(
                                                              name: string,
                                                              is: Is<A>,
                                                              validate: Validate<I, A>,
                                                              encode: Encode<A, O>,
                                                              type: Any
                                                              );

                                                                property type

                                                                readonly type: Any;

                                                                  class RecursiveType

                                                                  class RecursiveType<C extends Any, A = any, O = A, I = unknown> extends Type<
                                                                  A,
                                                                  O,
                                                                  I
                                                                  > {}
                                                                  • 1.0.0

                                                                  constructor

                                                                  constructor(
                                                                  name: string,
                                                                  is: Is<A>,
                                                                  validate: Validate<I, A>,
                                                                  encode: Encode<A, O>,
                                                                  runDefinition: () => C
                                                                  );

                                                                    property runDefinition

                                                                    runDefinition: () => C;

                                                                      property type

                                                                      readonly type: Any;
                                                                      • 1.0.0

                                                                      class RefinementType

                                                                      class RefinementType<C extends Any, A = any, O = A, I = unknown> extends Type<
                                                                      A,
                                                                      O,
                                                                      I
                                                                      > {}
                                                                      • 1.0.0

                                                                      constructor

                                                                      constructor(
                                                                      name: string,
                                                                      is: Is<A>,
                                                                      validate: Validate<I, A>,
                                                                      encode: Encode<A, O>,
                                                                      type: Any,
                                                                      predicate: Predicate<A>
                                                                      );

                                                                        property predicate

                                                                        readonly predicate: Predicate<A>;

                                                                          property type

                                                                          readonly type: Any;

                                                                            class StrictType

                                                                            class StrictType<P, A = any, O = A, I = unknown> extends Type<A, O, I> {}
                                                                            • 1.0.0

                                                                              Deprecated

                                                                            constructor

                                                                            constructor(
                                                                            name: string,
                                                                            is: Is<A>,
                                                                            validate: Validate<I, A>,
                                                                            encode: Encode<A, O>,
                                                                            props: {}
                                                                            );

                                                                              property props

                                                                              readonly props: {};

                                                                                class StringType

                                                                                class StringType extends Type<string> {}
                                                                                • 1.0.0

                                                                                constructor

                                                                                constructor();

                                                                                  class TaggedUnionType

                                                                                  class TaggedUnionType<
                                                                                  Tag extends string,
                                                                                  CS extends Array<Mixed>,
                                                                                  A = any,
                                                                                  O = A,
                                                                                  I = unknown
                                                                                  > extends UnionType<CS, A, O, I> {}
                                                                                  • 1.3.0

                                                                                    Deprecated

                                                                                  constructor

                                                                                  constructor(
                                                                                  name: string,
                                                                                  is: Is<A>,
                                                                                  validate: Validate<I, A>,
                                                                                  encode: Encode<A, O>,
                                                                                  codecs: Mixed[],
                                                                                  tag: string
                                                                                  );

                                                                                    property tag

                                                                                    readonly tag: string;

                                                                                      class TupleType

                                                                                      class TupleType<CS extends Array<Any>, A = any, O = A, I = unknown> extends Type<
                                                                                      A,
                                                                                      O,
                                                                                      I
                                                                                      > {}
                                                                                      • 1.0.0

                                                                                      constructor

                                                                                      constructor(
                                                                                      name: string,
                                                                                      is: Is<A>,
                                                                                      validate: Validate<I, A>,
                                                                                      encode: Encode<A, O>,
                                                                                      types: Any[]
                                                                                      );

                                                                                        property types

                                                                                        readonly types: Any[];

                                                                                          class Type

                                                                                          class Type<A, O = A, I = unknown> implements Decoder<I, A>, Encoder<A, O> {}
                                                                                          • Codec 1.0.0

                                                                                          constructor

                                                                                          constructor(
                                                                                          name: string,
                                                                                          is: Is<A>,
                                                                                          validate: Validate<I, A>,
                                                                                          encode: Encode<A, O>
                                                                                          );

                                                                                            property encode

                                                                                            readonly encode: Encode<A, O>;
                                                                                            • converts a value of type A to a value of type O

                                                                                            property is

                                                                                            readonly is: Is<A>;
                                                                                            • a custom type guard

                                                                                            property name

                                                                                            readonly name: string;
                                                                                            • a unique name for this codec

                                                                                            property validate

                                                                                            readonly validate: Validate<I, A>;
                                                                                            • succeeds if a value of type I can be decoded to a value of type A

                                                                                            method asDecoder

                                                                                            asDecoder: () => Decoder<I, A>;
                                                                                            • 1.0.0

                                                                                            method asEncoder

                                                                                            asEncoder: () => Encoder<A, O>;
                                                                                            • 1.0.0

                                                                                            method decode

                                                                                            decode: (i: I) => Either<Errors, A>;
                                                                                            • a version of validate with a default context 1.0.0

                                                                                            method pipe

                                                                                            pipe: <B, IB, A extends IB, OB extends A>(
                                                                                            this: Type<A, O, I>,
                                                                                            ab: Type<B, OB, IB>,
                                                                                            name?: string
                                                                                            ) => Type<B, O, I>;
                                                                                            • 1.0.0

                                                                                            class UndefinedType

                                                                                            class UndefinedType extends Type<undefined> {}
                                                                                            • 1.0.0

                                                                                            constructor

                                                                                            constructor();

                                                                                              class UnionType

                                                                                              class UnionType<CS extends Array<Any>, A = any, O = A, I = unknown> extends Type<
                                                                                              A,
                                                                                              O,
                                                                                              I
                                                                                              > {}
                                                                                              • 1.0.0

                                                                                              constructor

                                                                                              constructor(
                                                                                              name: string,
                                                                                              is: Is<A>,
                                                                                              validate: Validate<I, A>,
                                                                                              encode: Encode<A, O>,
                                                                                              types: Any[]
                                                                                              );

                                                                                                property types

                                                                                                readonly types: Any[];

                                                                                                  class UnknownType

                                                                                                  class UnknownType extends Type<unknown> {}
                                                                                                  • 1.5.0

                                                                                                  constructor

                                                                                                  constructor();

                                                                                                    class VoidType

                                                                                                    class VoidType extends Type<void> {}
                                                                                                    • 1.2.0

                                                                                                    constructor

                                                                                                    constructor();

                                                                                                      Interfaces

                                                                                                      interface Any

                                                                                                      interface Any extends Type<any, any, any> {}
                                                                                                      • 1.0.0

                                                                                                      interface AnyC

                                                                                                      interface AnyC extends AnyType {}
                                                                                                      • 1.5.3

                                                                                                      interface AnyProps

                                                                                                      interface AnyProps {}
                                                                                                      • 1.0.0

                                                                                                      index signature

                                                                                                      [key: string]: Any;

                                                                                                        interface ArrayC

                                                                                                        interface ArrayC<C extends Mixed>
                                                                                                        extends ArrayType<C, Array<TypeOf<C>>, Array<OutputOf<C>>, unknown> {}
                                                                                                        • 1.5.3

                                                                                                        interface BigIntC

                                                                                                        interface BigIntC extends BigIntType {}
                                                                                                        • 2.1.0

                                                                                                        interface BooleanC

                                                                                                        interface BooleanC extends BooleanType {}
                                                                                                        • 1.5.3

                                                                                                        interface Brand

                                                                                                        interface Brand<B> {}
                                                                                                        • 1.8.1

                                                                                                        property [_brand]

                                                                                                        readonly [_brand]: B;

                                                                                                          interface BrandC

                                                                                                          interface BrandC<C extends Any, B>
                                                                                                          extends RefinementType<C, Branded<TypeOf<C>, B>, OutputOf<C>, InputOf<C>> {}
                                                                                                          • 1.8.1

                                                                                                          interface Context

                                                                                                          interface Context extends ReadonlyArray<ContextEntry> {}
                                                                                                          • Decode error 1.0.0

                                                                                                          interface ContextEntry

                                                                                                          interface ContextEntry {}
                                                                                                          • Decode error 1.0.0

                                                                                                          property actual

                                                                                                          readonly actual?: unknown;
                                                                                                          • the input data

                                                                                                          property key

                                                                                                          readonly key: string;

                                                                                                            property type

                                                                                                            readonly type: Decoder<any, any>;

                                                                                                              interface Decoder

                                                                                                              interface Decoder<I, A> {}
                                                                                                              • Codec 1.0.0

                                                                                                              property decode

                                                                                                              readonly decode: Decode<I, A>;

                                                                                                                property name

                                                                                                                readonly name: string;

                                                                                                                  property validate

                                                                                                                  readonly validate: Validate<I, A>;

                                                                                                                    interface Encoder

                                                                                                                    interface Encoder<A, O> {}
                                                                                                                    • Codec 1.0.0

                                                                                                                    property encode

                                                                                                                    readonly encode: Encode<A, O>;

                                                                                                                      interface Errors

                                                                                                                      interface Errors extends Array<ValidationError> {}
                                                                                                                      • Decode error 1.0.0

                                                                                                                      interface ExactC

                                                                                                                      interface ExactC<C extends HasProps>
                                                                                                                      extends ExactType<C, TypeOf<C>, OutputOf<C>, InputOf<C>> {}
                                                                                                                      • 1.5.3

                                                                                                                      interface FunctionC

                                                                                                                      interface FunctionC extends FunctionType {}
                                                                                                                      • 1.5.3

                                                                                                                      interface HasPropsIntersection

                                                                                                                      interface HasPropsIntersection
                                                                                                                      extends IntersectionType<Array<HasProps>, any, any, any> {}
                                                                                                                      • 1.1.0

                                                                                                                      interface HasPropsReadonly

                                                                                                                      interface HasPropsReadonly extends ReadonlyType<HasProps, any, any, any> {}
                                                                                                                      • 1.1.0

                                                                                                                      interface HasPropsRefinement

                                                                                                                      interface HasPropsRefinement extends RefinementType<HasProps, any, any, any> {}
                                                                                                                      • 1.1.0

                                                                                                                      interface IntBrand

                                                                                                                      interface IntBrand {}
                                                                                                                      • 1.8.1

                                                                                                                      property Int

                                                                                                                      readonly Int: unique symbol;

                                                                                                                        interface IntersectionC

                                                                                                                        interface IntersectionC<CS extends [Mixed, Mixed, ...Array<Mixed>]>
                                                                                                                        extends IntersectionType<
                                                                                                                        CS,
                                                                                                                        CS extends {
                                                                                                                        length: 2;
                                                                                                                        }
                                                                                                                        ? TypeOf<CS[0]> & TypeOf<CS[1]>
                                                                                                                        : CS extends {
                                                                                                                        length: 3;
                                                                                                                        }
                                                                                                                        ? TypeOf<CS[0]> & TypeOf<CS[1]> & TypeOf<CS[2]>
                                                                                                                        : CS extends {
                                                                                                                        length: 4;
                                                                                                                        }
                                                                                                                        ? TypeOf<CS[0]> & TypeOf<CS[1]> & TypeOf<CS[2]> & TypeOf<CS[3]>
                                                                                                                        : CS extends {
                                                                                                                        length: 5;
                                                                                                                        }
                                                                                                                        ? TypeOf<CS[0]> &
                                                                                                                        TypeOf<CS[1]> &
                                                                                                                        TypeOf<CS[2]> &
                                                                                                                        TypeOf<CS[3]> &
                                                                                                                        TypeOf<CS[4]>
                                                                                                                        : unknown,
                                                                                                                        CS extends {
                                                                                                                        length: 2;
                                                                                                                        }
                                                                                                                        ? OutputOf<CS[0]> & OutputOf<CS[1]>
                                                                                                                        : CS extends {
                                                                                                                        length: 3;
                                                                                                                        }
                                                                                                                        ? OutputOf<CS[0]> & OutputOf<CS[1]> & OutputOf<CS[2]>
                                                                                                                        : CS extends {
                                                                                                                        length: 4;
                                                                                                                        }
                                                                                                                        ? OutputOf<CS[0]> & OutputOf<CS[1]> & OutputOf<CS[2]> & OutputOf<CS[3]>
                                                                                                                        : CS extends {
                                                                                                                        length: 5;
                                                                                                                        }
                                                                                                                        ? OutputOf<CS[0]> &
                                                                                                                        OutputOf<CS[1]> &
                                                                                                                        OutputOf<CS[2]> &
                                                                                                                        OutputOf<CS[3]> &
                                                                                                                        OutputOf<CS[4]>
                                                                                                                        : unknown,
                                                                                                                        unknown
                                                                                                                        > {}
                                                                                                                        • 1.5.3

                                                                                                                        interface KeyofC

                                                                                                                        interface KeyofC<
                                                                                                                        D extends {
                                                                                                                        [key: string]: unknown;
                                                                                                                        }
                                                                                                                        > extends KeyofType<D> {}
                                                                                                                        • 1.5.3

                                                                                                                        interface LiteralC

                                                                                                                        interface LiteralC<V extends LiteralValue> extends LiteralType<V> {}
                                                                                                                        • 1.5.3

                                                                                                                        interface Mixed

                                                                                                                        interface Mixed extends Type<any, any, unknown> {}
                                                                                                                        • 1.0.0

                                                                                                                        interface NeverC

                                                                                                                        interface NeverC extends NeverType {}
                                                                                                                        • 1.5.3

                                                                                                                        interface NullC

                                                                                                                        interface NullC extends NullType {}
                                                                                                                        • 1.5.3

                                                                                                                        interface NumberC

                                                                                                                        interface NumberC extends NumberType {}
                                                                                                                        • 1.5.3

                                                                                                                        interface ObjectC

                                                                                                                        interface ObjectC extends ObjectType {}
                                                                                                                        • 1.5.3

                                                                                                                          Deprecated

                                                                                                                        interface PartialC

                                                                                                                        interface PartialC<P extends Props>
                                                                                                                        extends PartialType<
                                                                                                                        P,
                                                                                                                        {
                                                                                                                        [K in keyof P]?: TypeOf<P[K]>;
                                                                                                                        },
                                                                                                                        {
                                                                                                                        [K in keyof P]?: OutputOf<P[K]>;
                                                                                                                        },
                                                                                                                        unknown
                                                                                                                        > {}
                                                                                                                        • 1.5.3

                                                                                                                        interface Props

                                                                                                                        interface Props {}
                                                                                                                        • 1.0.0

                                                                                                                        index signature

                                                                                                                        [key: string]: Mixed;

                                                                                                                          interface ReadonlyArrayC

                                                                                                                          interface ReadonlyArrayC<C extends Mixed>
                                                                                                                          extends ReadonlyArrayType<
                                                                                                                          C,
                                                                                                                          ReadonlyArray<TypeOf<C>>,
                                                                                                                          ReadonlyArray<OutputOf<C>>,
                                                                                                                          unknown
                                                                                                                          > {}
                                                                                                                          • 1.5.3

                                                                                                                          interface ReadonlyC

                                                                                                                          interface ReadonlyC<C extends Mixed>
                                                                                                                          extends ReadonlyType<C, Readonly<TypeOf<C>>, Readonly<OutputOf<C>>, unknown> {}
                                                                                                                          • 1.5.3

                                                                                                                          interface RecordC

                                                                                                                          interface RecordC<D extends Mixed, C extends Mixed>
                                                                                                                          extends DictionaryType<
                                                                                                                          D,
                                                                                                                          C,
                                                                                                                          {
                                                                                                                          [K in TypeOf<D>]: TypeOf<C>;
                                                                                                                          },
                                                                                                                          {
                                                                                                                          [K in OutputOf<D>]: OutputOf<C>;
                                                                                                                          },
                                                                                                                          unknown
                                                                                                                          > {}
                                                                                                                          • 1.5.3

                                                                                                                          interface RefinementC

                                                                                                                          interface RefinementC<C extends Any, B = TypeOf<C>>
                                                                                                                          extends RefinementType<C, B, OutputOf<C>, InputOf<C>> {}
                                                                                                                          • 1.5.3

                                                                                                                          interface StrictC

                                                                                                                          interface StrictC<P extends Props>
                                                                                                                          extends StrictType<
                                                                                                                          P,
                                                                                                                          {
                                                                                                                          [K in keyof P]: TypeOf<P[K]>;
                                                                                                                          },
                                                                                                                          {
                                                                                                                          [K in keyof P]: OutputOf<P[K]>;
                                                                                                                          },
                                                                                                                          unknown
                                                                                                                          > {}
                                                                                                                          • 1.5.3

                                                                                                                            Deprecated

                                                                                                                          interface StringC

                                                                                                                          interface StringC extends StringType {}
                                                                                                                          • 1.5.3

                                                                                                                          interface TaggedExact

                                                                                                                          interface TaggedExact<Tag extends string, A, O = A>
                                                                                                                          extends ExactType<Tagged<Tag>, A, O> {}
                                                                                                                          • 1.3.0

                                                                                                                            Deprecated

                                                                                                                          interface TaggedIntersection

                                                                                                                          interface TaggedIntersection<Tag extends string, A, O = A>
                                                                                                                          extends IntersectionType<TaggedIntersectionArgument<Tag>, A, O> {}
                                                                                                                          • 1.3.0

                                                                                                                            Deprecated

                                                                                                                          interface TaggedRefinement

                                                                                                                          interface TaggedRefinement<Tag extends string, A, O = A>
                                                                                                                          extends RefinementType<Tagged<Tag>, A, O> {}
                                                                                                                          • 1.3.0

                                                                                                                            Deprecated

                                                                                                                          interface TaggedUnion

                                                                                                                          interface TaggedUnion<Tag extends string, A, O = A>
                                                                                                                          extends UnionType<Array<Tagged<Tag>>, A, O> {}
                                                                                                                          • 1.3.0

                                                                                                                            Deprecated

                                                                                                                          interface TaggedUnionC

                                                                                                                          interface TaggedUnionC<
                                                                                                                          Tag extends string,
                                                                                                                          CS extends [Mixed, Mixed, ...Array<Mixed>]
                                                                                                                          > extends TaggedUnionType<
                                                                                                                          Tag,
                                                                                                                          CS,
                                                                                                                          TypeOf<CS[number]>,
                                                                                                                          OutputOf<CS[number]>,
                                                                                                                          unknown
                                                                                                                          > {}
                                                                                                                          • 1.5.3

                                                                                                                            Deprecated

                                                                                                                          interface TupleC

                                                                                                                          interface TupleC<CS extends [Mixed, ...Array<Mixed>]>
                                                                                                                          extends TupleType<
                                                                                                                          CS,
                                                                                                                          CS extends {
                                                                                                                          length: 1;
                                                                                                                          }
                                                                                                                          ? [TypeOf<CS[0]>]
                                                                                                                          : CS extends {
                                                                                                                          length: 2;
                                                                                                                          }
                                                                                                                          ? [TypeOf<CS[0]>, TypeOf<CS[1]>]
                                                                                                                          : CS extends {
                                                                                                                          length: 3;
                                                                                                                          }
                                                                                                                          ? [TypeOf<CS[0]>, TypeOf<CS[1]>, TypeOf<CS[2]>]
                                                                                                                          : CS extends {
                                                                                                                          length: 4;
                                                                                                                          }
                                                                                                                          ? [TypeOf<CS[0]>, TypeOf<CS[1]>, TypeOf<CS[2]>, TypeOf<CS[3]>]
                                                                                                                          : CS extends {
                                                                                                                          length: 5;
                                                                                                                          }
                                                                                                                          ? [
                                                                                                                          TypeOf<CS[0]>,
                                                                                                                          TypeOf<CS[1]>,
                                                                                                                          TypeOf<CS[2]>,
                                                                                                                          TypeOf<CS[3]>,
                                                                                                                          TypeOf<CS[4]>
                                                                                                                          ]
                                                                                                                          : unknown,
                                                                                                                          CS extends {
                                                                                                                          length: 1;
                                                                                                                          }
                                                                                                                          ? [OutputOf<CS[0]>]
                                                                                                                          : CS extends {
                                                                                                                          length: 2;
                                                                                                                          }
                                                                                                                          ? [OutputOf<CS[0]>, OutputOf<CS[1]>]
                                                                                                                          : CS extends {
                                                                                                                          length: 3;
                                                                                                                          }
                                                                                                                          ? [OutputOf<CS[0]>, OutputOf<CS[1]>, OutputOf<CS[2]>]
                                                                                                                          : CS extends {
                                                                                                                          length: 4;
                                                                                                                          }
                                                                                                                          ? [OutputOf<CS[0]>, OutputOf<CS[1]>, OutputOf<CS[2]>, OutputOf<CS[3]>]
                                                                                                                          : CS extends {
                                                                                                                          length: 5;
                                                                                                                          }
                                                                                                                          ? [
                                                                                                                          OutputOf<CS[0]>,
                                                                                                                          OutputOf<CS[1]>,
                                                                                                                          OutputOf<CS[2]>,
                                                                                                                          OutputOf<CS[3]>,
                                                                                                                          OutputOf<CS[4]>
                                                                                                                          ]
                                                                                                                          : unknown,
                                                                                                                          unknown
                                                                                                                          > {}
                                                                                                                          • 1.5.3

                                                                                                                          interface TypeC

                                                                                                                          interface TypeC<P extends Props>
                                                                                                                          extends InterfaceType<
                                                                                                                          P,
                                                                                                                          {
                                                                                                                          [K in keyof P]: TypeOf<P[K]>;
                                                                                                                          },
                                                                                                                          {
                                                                                                                          [K in keyof P]: OutputOf<P[K]>;
                                                                                                                          },
                                                                                                                          unknown
                                                                                                                          > {}
                                                                                                                          • 1.5.3

                                                                                                                          interface UndefinedC

                                                                                                                          interface UndefinedC extends UndefinedType {}
                                                                                                                          • 1.5.3

                                                                                                                          interface UnionC

                                                                                                                          interface UnionC<CS extends [Mixed, Mixed, ...Array<Mixed>]>
                                                                                                                          extends UnionType<CS, TypeOf<CS[number]>, OutputOf<CS[number]>, unknown> {}
                                                                                                                          • 1.5.3

                                                                                                                          interface UnknownArrayC

                                                                                                                          interface UnknownArrayC extends AnyArrayType {}
                                                                                                                          • 1.5.3

                                                                                                                          interface UnknownC

                                                                                                                          interface UnknownC extends UnknownType {}
                                                                                                                          • 1.5.3

                                                                                                                          interface UnknownRecordC

                                                                                                                          interface UnknownRecordC extends AnyDictionaryType {}
                                                                                                                          • 1.5.3

                                                                                                                          interface ValidationError

                                                                                                                          interface ValidationError {}
                                                                                                                          • Decode error 1.0.0

                                                                                                                          property context

                                                                                                                          readonly context: Context;
                                                                                                                          • where the error originated

                                                                                                                          property message

                                                                                                                          readonly message?: string;
                                                                                                                          • optional custom error message

                                                                                                                          property value

                                                                                                                          readonly value: unknown;
                                                                                                                          • the offending (sub)value

                                                                                                                          interface VoidC

                                                                                                                          interface VoidC extends VoidType {}
                                                                                                                          • 1.5.3

                                                                                                                          Type Aliases

                                                                                                                          type Branded

                                                                                                                          type Branded<A, B> = A & Brand<B>;
                                                                                                                          • 1.8.1

                                                                                                                          type Compact

                                                                                                                          type Compact<A> = {
                                                                                                                          [K in keyof A]: A[K];
                                                                                                                          };
                                                                                                                          • 1.4.2

                                                                                                                            Deprecated

                                                                                                                          type Decode

                                                                                                                          type Decode<I, A> = (i: I) => Validation<A>;
                                                                                                                          • 1.0.0

                                                                                                                          type Encode

                                                                                                                          type Encode<A, O> = (a: A) => O;
                                                                                                                          • 1.0.0

                                                                                                                          type Exact

                                                                                                                          type Exact<T, X extends T> = T & {
                                                                                                                          [K in ({
                                                                                                                          [K in keyof X]: K;
                                                                                                                          } & {
                                                                                                                          [K in keyof T]: never;
                                                                                                                          } & {
                                                                                                                          [key: string]: never;
                                                                                                                          })[keyof X]]?: never;
                                                                                                                          };
                                                                                                                          • 1.1.0

                                                                                                                            Deprecated

                                                                                                                          type HasProps

                                                                                                                          type HasProps =
                                                                                                                          | HasPropsRefinement
                                                                                                                          | HasPropsReadonly
                                                                                                                          | HasPropsIntersection
                                                                                                                          | InterfaceType<any, any, any, any>
                                                                                                                          | StrictType<any, any, any, any>
                                                                                                                          | PartialType<any, any, any, any>;
                                                                                                                          • 1.1.0

                                                                                                                          type InputOf

                                                                                                                          type InputOf<C extends Any> = C['_I'];
                                                                                                                          • Codec 1.0.0

                                                                                                                          type Int

                                                                                                                          type Int = Branded<number, IntBrand>;
                                                                                                                          • 1.8.1

                                                                                                                          type Is

                                                                                                                          type Is<A> = (u: unknown) => u is A;
                                                                                                                          • 1.0.0

                                                                                                                          type mixed

                                                                                                                          type mixed = unknown;
                                                                                                                          • Use unknown instead.

                                                                                                                            1.0.0

                                                                                                                            Deprecated

                                                                                                                          type OutputOf

                                                                                                                          type OutputOf<C extends Any> = C['_O'];
                                                                                                                          • Codec 1.0.0

                                                                                                                          type OutputOfDictionary

                                                                                                                          type OutputOfDictionary<D extends Any, C extends Any> = {
                                                                                                                          [K in OutputOf<D>]: OutputOf<C>;
                                                                                                                          };
                                                                                                                          • 1.0.0

                                                                                                                          type OutputOfPartialProps

                                                                                                                          type OutputOfPartialProps<P extends AnyProps> = {
                                                                                                                          [K in keyof P]?: OutputOf<P[K]>;
                                                                                                                          };
                                                                                                                          • 1.0.0

                                                                                                                          type OutputOfProps

                                                                                                                          type OutputOfProps<P extends AnyProps> = {
                                                                                                                          [K in keyof P]: OutputOf<P[K]>;
                                                                                                                          };
                                                                                                                          • 1.0.0

                                                                                                                          type PropsOf

                                                                                                                          type PropsOf<
                                                                                                                          T extends {
                                                                                                                          props: any;
                                                                                                                          }
                                                                                                                          > = T['props'];
                                                                                                                          • 1.0.0

                                                                                                                            Deprecated

                                                                                                                          type Tagged

                                                                                                                          type Tagged<Tag extends string, A = any, O = A> =
                                                                                                                          | InterfaceType<TaggedProps<Tag>, A, O>
                                                                                                                          | StrictType<TaggedProps<Tag>, A, O>
                                                                                                                          | TaggedRefinement<Tag, A, O>
                                                                                                                          | TaggedUnion<Tag, A, O>
                                                                                                                          | TaggedIntersection<Tag, A, O>
                                                                                                                          | TaggedExact<Tag, A, O>
                                                                                                                          | RecursiveType<any, A, O>;
                                                                                                                          • 1.3.0

                                                                                                                            Deprecated

                                                                                                                          type TaggedIntersectionArgument

                                                                                                                          type TaggedIntersectionArgument<Tag extends string> =
                                                                                                                          | [Tagged<Tag>]
                                                                                                                          | [Tagged<Tag>, Mixed]
                                                                                                                          | [Mixed, Tagged<Tag>]
                                                                                                                          | [Tagged<Tag>, Mixed, Mixed]
                                                                                                                          | [Mixed, Tagged<Tag>, Mixed]
                                                                                                                          | [Mixed, Mixed, Tagged<Tag>]
                                                                                                                          | [Tagged<Tag>, Mixed, Mixed, Mixed]
                                                                                                                          | [Mixed, Tagged<Tag>, Mixed, Mixed]
                                                                                                                          | [Mixed, Mixed, Tagged<Tag>, Mixed]
                                                                                                                          | [Mixed, Mixed, Mixed, Tagged<Tag>]
                                                                                                                          | [Tagged<Tag>, Mixed, Mixed, Mixed, Mixed]
                                                                                                                          | [Mixed, Tagged<Tag>, Mixed, Mixed, Mixed]
                                                                                                                          | [Mixed, Mixed, Tagged<Tag>, Mixed, Mixed]
                                                                                                                          | [Mixed, Mixed, Mixed, Tagged<Tag>, Mixed]
                                                                                                                          | [Mixed, Mixed, Mixed, Mixed, Tagged<Tag>];
                                                                                                                          • 1.3.0

                                                                                                                            Deprecated

                                                                                                                          type TaggedProps

                                                                                                                          type TaggedProps<Tag extends string> = {
                                                                                                                          [K in Tag]: LiteralType<any>;
                                                                                                                          };
                                                                                                                          • 1.3.0

                                                                                                                            Deprecated

                                                                                                                          type TypeOf

                                                                                                                          type TypeOf<C extends Any> = C['_A'];
                                                                                                                          • Codec 1.0.0

                                                                                                                          type TypeOfDictionary

                                                                                                                          type TypeOfDictionary<D extends Any, C extends Any> = {
                                                                                                                          [K in TypeOf<D>]: TypeOf<C>;
                                                                                                                          };
                                                                                                                          • 1.0.0

                                                                                                                          type TypeOfPartialProps

                                                                                                                          type TypeOfPartialProps<P extends AnyProps> = {
                                                                                                                          [K in keyof P]?: TypeOf<P[K]>;
                                                                                                                          };
                                                                                                                          • 1.0.0

                                                                                                                          type TypeOfProps

                                                                                                                          type TypeOfProps<P extends AnyProps> = {
                                                                                                                          [K in keyof P]: TypeOf<P[K]>;
                                                                                                                          };
                                                                                                                          • 1.0.0

                                                                                                                          type Validate

                                                                                                                          type Validate<I, A> = (i: I, context: Context) => Validation<A>;
                                                                                                                          • 1.0.0

                                                                                                                          type Validation

                                                                                                                          type Validation<A> = Either<Errors, A>;
                                                                                                                          • Decode error 1.0.0

                                                                                                                          Package Files (1)

                                                                                                                          Dependencies (0)

                                                                                                                          No dependencies.

                                                                                                                          Dev Dependencies (0)

                                                                                                                          No dev dependencies.

                                                                                                                          Peer Dependencies (1)

                                                                                                                          Badge

                                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/io-ts.

                                                                                                                          • Markdown
                                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/io-ts)
                                                                                                                          • HTML
                                                                                                                            <a href="https://www.jsdocs.io/package/io-ts"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>