/** * @since 0.5.0 */ import { Either } from 'fp-ts/lib/Either' import * as t from 'io-ts' /** * @since 0.5.18 */ export declare type LeftOutput = { _tag: 'Left' left: L } /** * @since 0.5.18 */ export declare type RightOutput = { _tag: 'Right' right: R } /** * @since 0.5.18 */ export declare type EitherOutput = LeftOutput | RightOutput /** * @since 0.5.0 */ export interface EitherC extends t.Type, t.TypeOf>, EitherOutput, t.OutputOf>, unknown> {} /** * Given a codec representing a type `L` and a codec representing a type `A`, returns a codec representing `Either` that is able to deserialize * the JSON representation of an `Either`. * * @example * import { either } from 'io-ts-types/lib/either' * import { left, right } from 'fp-ts/lib/Either' * import * as t from 'io-ts' * import { PathReporter } from 'io-ts/lib/PathReporter' * * const T = either(t.string, t.number) * * assert.deepStrictEqual(T.decode(right(1)), right(right(1))) * assert.deepStrictEqual(T.decode(left('a')), right(left('a'))) * assert.deepStrictEqual(PathReporter.report(T.decode(right('a'))), ['Invalid value "a" supplied to : Either/1: Right/right: number']) * * @since 0.5.0 */ export declare function either( leftCodec: L, rightCodec: R, name?: string ): EitherC