import Maybe from '../../Maybe'; import Either from '../../Either'; import Encode from '../Encode'; import _Error from './Error'; import * as _ from './Decoder'; interface RequiredKeyValue { (decoder: _.Decoder): _.Decoder>; (convertKey: (key: string) => Either, decoder: _.Decoder): _.Decoder>; } interface OptionalKeyValue { (decoder: _.Decoder): _.Decoder>>; (convertKey: (key: string) => Either, decoder: _.Decoder): _.Decoder>>; } interface RequiredDict { (decoder: _.Decoder): _.Decoder<{ [key: string]: T; }>; } interface OptionalDict { (decoder: _.Decoder): _.Decoder>; } interface RequiredList { (decoder: _.Decoder): _.Decoder>; } interface OptionaldList { (decoder: _.Decoder): _.Decoder>>; } interface RequiredShape { (object: { [K in keyof T]: _.Decoder; }): _.Decoder; } interface OptionalShape { (object: { [K in keyof T]: _.Decoder; }): _.Decoder>; } interface RequiredOf { (decoder: _.Decoder): _.Decoder; } interface OptionalOf { (decoder: _.Decoder): _.Decoder>; } interface RequiredOneOf { (decoders: Array<_.Decoder>): _.Decoder; } interface OptionalOneOf { (decoders: Array<_.Decoder>): _.Decoder>; } interface RequiredEnums { (variants: Array<[string | number | boolean | null, T]>): _.Decoder; } interface OptionalEnums { (variants: Array<[string | number | boolean | null, T]>): _.Decoder>; } interface RequiredLazy { (callDecoder: () => _.Decoder): _.Decoder; } interface OptionalLazy { (callDecoder: () => _.Decoder): _.Decoder>; } interface Common { string: unknown; boolean: unknown; int: unknown; float: unknown; keyValue: unknown; shape: unknown; list: unknown; dict: unknown; of: unknown; oneOf: unknown; enums: unknown; field(key: string): unknown; index(position: number): unknown; at(path: Array): unknown; } interface WithOptional extends Common { optional: Decode.Optional; value: unknown; lazy: unknown; } export declare namespace Decode { interface Error extends _Error { } const Error: typeof _Error; namespace Error { type Pattern = _Error.Pattern; } interface Value extends Encode.Value { } abstract class Decoder extends _.Decoder { } interface Optional extends Common { string: _.Decoder>; boolean: _.Decoder>; int: _.Decoder>; float: _.Decoder>; shape: OptionalShape; list: OptionaldList; keyValue: OptionalKeyValue; dict: OptionalDict; of: OptionalOf; oneOf: OptionalOneOf; enums: OptionalEnums; field(name: string): OptionalPath; index(position: number): OptionalPath; at(path: Array): OptionalPath; } interface Path extends WithOptional { optional: Optional; string: _.Decoder; boolean: _.Decoder; int: _.Decoder; float: _.Decoder; value: _.Decoder; shape: RequiredShape; list: RequiredList; keyValue: RequiredKeyValue; dict: RequiredDict; of: RequiredOf; oneOf: RequiredOneOf; enums: RequiredEnums; lazy: RequiredLazy; field(name: string): Path; index(position: number): Path; at(path: Array): Path; } interface OptionalPath extends WithOptional { optional: Optional; string: _.Decoder>; boolean: _.Decoder>; int: _.Decoder>; float: _.Decoder>; value: _.Decoder>; shape: OptionalShape; list: OptionaldList; keyValue: OptionalKeyValue; dict: OptionalDict; of: OptionalOf; oneOf: OptionalOneOf; enums: OptionalEnums; lazy: OptionalLazy; field(name: string): OptionalPath; index(position: number): OptionalPath; at(path: Array): OptionalPath; } const value: _.Value; const string: Decoder; const boolean: Decoder; const int: Decoder; const float: Decoder; const fail: (message: string) => Decoder; const succeed: (value: T) => Decoder; const shape: RequiredShape; const list: RequiredList; const keyValue: RequiredKeyValue; const dict: (decoder: Decoder) => Decoder<{ [key: string]: T; }>; const oneOf: RequiredOneOf; const enums: RequiredEnums; const lazy: RequiredLazy; const field: (name: string) => Path; const index: (position: number) => Path; const at: (path: (string | number)[]) => Path; const optional: Optional; const fromEither: (either: Either) => Decoder; const fromMaybe: (message: string, maybe: Maybe) => Decoder; } export { Error } from './Error'; export { Value } from '../Encode'; export { Decoder } from './Decoder'; export interface Path extends Decode.Path { } export interface OptionalPath extends Decode.OptionalPath { } export interface Optional extends Decode.Optional { } export declare const value: _.Value; export declare const string: Decode.Decoder; export declare const boolean: Decode.Decoder; export declare const int: Decode.Decoder; export declare const float: Decode.Decoder; export declare const fail: (message: string) => Decode.Decoder; export declare const succeed: (value: T) => Decode.Decoder; export declare const shape: RequiredShape; export declare const list: RequiredList; export declare const keyValue: RequiredKeyValue; export declare const dict: (decoder: Decode.Decoder) => Decode.Decoder<{ [key: string]: T; }>; export declare const oneOf: RequiredOneOf; export declare const enums: RequiredEnums; export declare const lazy: RequiredLazy; export declare const field: (name: string) => Decode.Path; export declare const index: (position: number) => Decode.Path; export declare const at: (path: (string | number)[]) => Decode.Path; export declare const optional: Decode.Optional; export declare const fromEither: (either: Either) => Decode.Decoder; export declare const fromMaybe: (message: string, maybe: Maybe) => Decode.Decoder; export default Decode;