/** * @since 0.5.0 */ import { Option } from 'fp-ts/lib/Option' import * as t from 'io-ts' declare const None: t.ExactC< t.TypeC<{ _tag: t.LiteralC<'None'> }> > /** * @since 0.5.18 */ export declare type NoneOutput = t.OutputOf /** * @since 0.5.18 */ export declare type SomeOutput = { _tag: 'Some' value: A } /** * @since 0.5.18 */ export declare type OptionOutput = NoneOutput | SomeOutput /** * Given a codec representing a type `A`, returns a codec representing `Option` that is able to deserialize * the JSON representation of an `Option`. * * @example * import { option } from 'io-ts-types/lib/option' * import { right } from 'fp-ts/lib/Either' * import { none, some } from 'fp-ts/lib/Option' * import * as t from 'io-ts' * import { PathReporter } from 'io-ts/lib/PathReporter' * * const T = option(t.number) * * assert.deepStrictEqual(T.decode(none), right(none)) * assert.deepStrictEqual(T.decode(some(1)), right(some(1))) * assert.deepStrictEqual(PathReporter.report(T.decode(some('a'))), ['Invalid value "a" supplied to : Option/1: Some/value: number']) * * @since 0.5.0 */ export interface OptionC extends t.Type>, OptionOutput>, unknown> {} /** * @since 0.5.0 */ export declare function option(codec: C, name?: string): OptionC export {}