Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

LimitedFields

LimitedFields<T, F>: {[ P in F]: T[P] }

Returns a new type that has only the F fields of type T.

Type parameters

  • T

  • F: keyof T

Omit

Omit<T, K>: Pick<T, Exclude<keyof T, K>>

From T omit a set of properties K

Type parameters

  • T

  • K: keyof T

PromiseType

PromiseType<T>: T extends Promise<infer A> ? A : never

Returns the type A if T is a Promise<A>, or else returns never

Type parameters

  • T

ReplaceProp1

ReplaceProp1<T, P1, A>: {[ K in P1]: A } & Pick<T, Exclude<keyof T, P1>>

Type parameters

  • T

  • P1: keyof T

  • A

ReplaceProp2

ReplaceProp2<T, P1, P2, A>: {[ K in P1]: ReplaceProp1<T[K], P2, A> } & Pick<T, Exclude<keyof T, P1>>

Type parameters

  • T

  • P1: keyof T

  • P2: keyof T[P1]

  • A

RequiredProp1

RequiredProp1<T, P1>: ReplaceProp1<T, P1, NonNullable<T[P1]>>

Removes null/undefined types from T[P1]

Type parameters

  • T

  • P1: keyof T

RequiredProp2

RequiredProp2<T, P1, P2>: ReplaceProp2<T, P1, P2, NonNullable<T[P1][P2]>>

Removes null/undefined types from T[P1][P2]

Type parameters

  • T

  • P1: keyof T

  • P2: keyof T[P1]

Tagged

Tagged<T, A, O, I>: t.Type<A & T, O & T, I>

An io-ts Type tagged with T

Type parameters

  • T

  • A

  • O = A

  • I = t.mixed

UntagBasicType

UntagBasicType<A>: A extends string ? string : A extends number ? number : A extends boolean ? boolean : never

Removes any extra tags from a type that extends a basic type.

Basic types: string, number, boolean

Type parameters

  • A

Functions

Const enumType

  • enumType<E>(e: object, name: string): Type<E, E, unknown>
  • Creates an io-ts Type from an enum

    Type parameters

    • E

    Parameters

    • e: object
    • name: string

    Returns Type<E, E, unknown>

Const isObject

  • isObject(o: {}): boolean
  • True when the input is an object (and not array).

    Parameters

    • o: {}

    Returns boolean

Const pick

  • pick<T, K>(props: readonly K[], obj: T): Pick<T, K>
  • Returns a subset of the input objects fields.

    Type parameters

    • T

    • K: string | number | symbol

    Parameters

    • props: readonly K[]

      an array of keys to preserve

    • obj: T

      the input object

    Returns Pick<T, K>

Const readonlySetType

  • readonlySetType<E>(o: Type<E, unknown, unknown>, name: string): Type<ReadonlySet<E>, unknown, unknown>
  • Creates an io-ts Type from a ReadonlySet

    Type parameters

    • E

    Parameters

    • o: Type<E, unknown, unknown>
    • name: string

    Returns Type<ReadonlySet<E>, unknown, unknown>

Const replaceProp1

  • replaceProp1<A, O, I, P, A1, O1, I1>(type: Type<A, O, I>, p: P, typeB: Type<A1, O1, I1>, name?: string): Type<ReplaceProp1<A, P, A1>, O, I>
  • Type parameters

    • A

    • O

    • I

    • P: string | number | symbol

    • A1

    • O1

    • I1

    Parameters

    • type: Type<A, O, I>
    • p: P
    • typeB: Type<A1, O1, I1>
    • Optional name: string

    Returns Type<ReplaceProp1<A, P, A1>, O, I>

Const requiredProp1

  • requiredProp1<A, O, I, P>(type: Type<A, O, I>, p: P, name?: string): Type<ReplaceProp1<A, P, NonNullable<A[P]>>, O, I>
  • Type parameters

    • A

    • O

    • I

    • P: string | number | symbol

    Parameters

    • type: Type<A, O, I>
    • p: P
    • Optional name: string

    Returns Type<ReplaceProp1<A, P, NonNullable<A[P]>>, O, I>

strictInterfaceWithOptionals

  • strictInterfaceWithOptionals<R, O>(required: R, optional: O, name: string): t.Type<t.TypeOfProps<R> & t.TypeOfPartialProps<O>, t.OutputOfProps<R> & t.OutputOfPartialProps<O>>
  • Return a new type that validates successfully only when the instance (object) contains no unknown properties.

    See https://github.com/gcanti/io-ts/issues/106

    \required

    required properties

    optional

    optional object properties

    Type parameters

    • R: Props

    • O: Props

    Parameters

    • required: R
    • optional: O
    • name: string

    Returns t.Type<t.TypeOfProps<R> & t.TypeOfPartialProps<O>, t.OutputOfProps<R> & t.OutputOfPartialProps<O>>

Const tag

  • tag<T>(): <A, O, I>(type: Type<A, O, I>) => Tagged<T, A, O, I>
  • Tags an io-ts type with an interface T

    Type parameters

    • T

    Returns <A, O, I>(type: Type<A, O, I>) => Tagged<T, A, O, I>

      • <A, O, I>(type: Type<A, O, I>): Tagged<T, A, O, I>
      • Type parameters

        • A

        • O = A

        • I = unknown

        Parameters

        • type: Type<A, O, I>

        Returns Tagged<T, A, O, I>

untag

  • Returns the passed tagged basic value after converting it to its basic type.

    Type parameters

    • T

    Parameters

    • a: T

    Returns UntagBasicType<T>

withDefault

  • withDefault<T>(type: T, defaultValue: t.TypeOf<T>): t.Type<t.TypeOf<T>, any>

withoutUndefinedValues

  • withoutUndefinedValues<T, K>(obj: T): T
  • Return an object filtering out keys that point to undefined values.

    Type parameters

    • T

    • K: string | number | symbol

    Parameters

    • obj: T

    Returns T

Legend

  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Interface
  • Interface with type parameter
  • Enumeration
  • Class with type parameter

Generated using TypeDoc