UNPKG

28.8 kBTypeScriptView Raw
1/**
2 * @since 1.0.0
3 */
4import { Either } from 'fp-ts/es6/Either';
5import { Predicate, Refinement } from 'fp-ts/es6/function';
6/**
7 * @since 1.0.0
8 */
9export interface ContextEntry {
10 readonly key: string;
11 readonly type: Decoder<any, any>;
12 /** the input data */
13 readonly actual?: unknown;
14}
15/**
16 * @since 1.0.0
17 */
18export interface Context extends ReadonlyArray<ContextEntry> {
19}
20/**
21 * @since 1.0.0
22 */
23export interface ValidationError {
24 /** the offending (sub)value */
25 readonly value: unknown;
26 /** where the error originated */
27 readonly context: Context;
28 /** optional custom error message */
29 readonly message?: string;
30}
31/**
32 * @since 1.0.0
33 */
34export interface Errors extends Array<ValidationError> {
35}
36/**
37 * @since 1.0.0
38 */
39export declare type Validation<A> = Either<Errors, A>;
40/**
41 * @since 1.0.0
42 */
43export declare type Is<A> = (u: unknown) => u is A;
44/**
45 * @since 1.0.0
46 */
47export declare type Validate<I, A> = (i: I, context: Context) => Validation<A>;
48/**
49 * @since 1.0.0
50 */
51export declare type Decode<I, A> = (i: I) => Validation<A>;
52/**
53 * @since 1.0.0
54 */
55export declare type Encode<A, O> = (a: A) => O;
56/**
57 * @since 1.0.0
58 */
59export interface Any extends Type<any, any, any> {
60}
61/**
62 * @since 1.0.0
63 */
64export interface Mixed extends Type<any, any, unknown> {
65}
66/**
67 * @since 1.0.0
68 */
69export declare type TypeOf<C extends Any> = C['_A'];
70/**
71 * @since 1.0.0
72 */
73export declare type InputOf<C extends Any> = C['_I'];
74/**
75 * @since 1.0.0
76 */
77export declare type OutputOf<C extends Any> = C['_O'];
78/**
79 * @since 1.0.0
80 */
81export interface Decoder<I, A> {
82 readonly name: string;
83 readonly validate: Validate<I, A>;
84 readonly decode: Decode<I, A>;
85}
86/**
87 * @since 1.0.0
88 */
89export interface Encoder<A, O> {
90 readonly encode: Encode<A, O>;
91}
92/**
93 * @since 1.0.0
94 */
95export declare class Type<A, O = A, I = unknown> implements Decoder<I, A>, Encoder<A, O> {
96 /** a unique name for this codec */
97 readonly name: string;
98 /** a custom type guard */
99 readonly is: Is<A>;
100 /** succeeds if a value of type I can be decoded to a value of type A */
101 readonly validate: Validate<I, A>;
102 /** converts a value of type A to a value of type O */
103 readonly encode: Encode<A, O>;
104 /**
105 * @since 1.0.0
106 */
107 readonly _A: A;
108 /**
109 * @since 1.0.0
110 */
111 readonly _O: O;
112 /**
113 * @since 1.0.0
114 */
115 readonly _I: I;
116 constructor(
117 /** a unique name for this codec */
118 name: string,
119 /** a custom type guard */
120 is: Is<A>,
121 /** succeeds if a value of type I can be decoded to a value of type A */
122 validate: Validate<I, A>,
123 /** converts a value of type A to a value of type O */
124 encode: Encode<A, O>);
125 /**
126 * @since 1.0.0
127 */
128 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>;
129 /**
130 * @since 1.0.0
131 */
132 asDecoder(): Decoder<I, A>;
133 /**
134 * @since 1.0.0
135 */
136 asEncoder(): Encoder<A, O>;
137 /**
138 * a version of `validate` with a default context
139 * @since 1.0.0
140 */
141 decode(i: I): Validation<A>;
142}
143/**
144 * @since 1.0.0
145 */
146export declare const identity: <A>(a: A) => A;
147/**
148 * @since 1.0.0
149 */
150export declare const getFunctionName: (f: Function) => string;
151/**
152 * @since 1.0.0
153 */
154export declare const getContextEntry: (key: string, decoder: Decoder<any, any>) => ContextEntry;
155/**
156 * @since 1.0.0
157 */
158export declare const appendContext: (c: Context, key: string, decoder: Decoder<any, any>, actual?: unknown) => Context;
159/**
160 * @since 1.0.0
161 */
162export declare const failures: <T>(errors: Errors) => Validation<T>;
163/**
164 * @since 1.0.0
165 */
166export declare const failure: <T>(value: unknown, context: Context, message?: string | undefined) => Either<Errors, T>;
167/**
168 * @since 1.0.0
169 */
170export declare const success: <T>(value: T) => Validation<T>;
171/**
172 * @since 1.0.0
173 */
174export declare class NullType extends Type<null> {
175 /**
176 * @since 1.0.0
177 */
178 readonly _tag: 'NullType';
179 constructor();
180}
181/**
182 * @since 1.5.3
183 */
184export interface NullC extends NullType {
185}
186/**
187 * @since 1.0.0
188 */
189export declare const nullType: NullC;
190/**
191 * @since 1.0.0
192 */
193export declare class UndefinedType extends Type<undefined> {
194 /**
195 * @since 1.0.0
196 */
197 readonly _tag: 'UndefinedType';
198 constructor();
199}
200/**
201 * @since 1.5.3
202 */
203export interface UndefinedC extends UndefinedType {
204}
205declare const undefinedType: UndefinedC;
206/**
207 * @since 1.2.0
208 */
209export declare class VoidType extends Type<void> {
210 /**
211 * @since 1.0.0
212 */
213 readonly _tag: 'VoidType';
214 constructor();
215}
216/**
217 * @since 1.5.3
218 */
219export interface VoidC extends VoidType {
220}
221/**
222 * @since 1.2.0
223 */
224export declare const voidType: VoidC;
225/**
226 * @since 1.5.0
227 */
228export declare class UnknownType extends Type<unknown> {
229 /**
230 * @since 1.0.0
231 */
232 readonly _tag: 'UnknownType';
233 constructor();
234}
235/**
236 * @since 1.5.3
237 */
238export interface UnknownC extends UnknownType {
239}
240/**
241 * @since 1.5.0
242 */
243export declare const unknown: UnknownC;
244/**
245 * @since 1.0.0
246 */
247export declare class StringType extends Type<string> {
248 /**
249 * @since 1.0.0
250 */
251 readonly _tag: 'StringType';
252 constructor();
253}
254/**
255 * @since 1.5.3
256 */
257export interface StringC extends StringType {
258}
259/**
260 * @since 1.0.0
261 */
262export declare const string: StringC;
263/**
264 * @since 1.0.0
265 */
266export declare class NumberType extends Type<number> {
267 /**
268 * @since 1.0.0
269 */
270 readonly _tag: 'NumberType';
271 constructor();
272}
273/**
274 * @since 1.5.3
275 */
276export interface NumberC extends NumberType {
277}
278/**
279 * @since 1.0.0
280 */
281export declare const number: NumberC;
282/**
283 * @since 2.1.0
284 */
285export declare class BigIntType extends Type<bigint> {
286 /**
287 * @since 1.0.0
288 */
289 readonly _tag: 'BigIntType';
290 constructor();
291}
292/**
293 * @since 2.1.0
294 */
295export interface BigIntC extends BigIntType {
296}
297/**
298 * @since 2.1.0
299 */
300export declare const bigint: BigIntC;
301/**
302 * @since 1.0.0
303 */
304export declare class BooleanType extends Type<boolean> {
305 /**
306 * @since 1.0.0
307 */
308 readonly _tag: 'BooleanType';
309 constructor();
310}
311/**
312 * @since 1.5.3
313 */
314export interface BooleanC extends BooleanType {
315}
316/**
317 * @since 1.0.0
318 */
319export declare const boolean: BooleanC;
320/**
321 * @since 1.0.0
322 */
323export declare class AnyArrayType extends Type<Array<unknown>> {
324 /**
325 * @since 1.0.0
326 */
327 readonly _tag: 'AnyArrayType';
328 constructor();
329}
330/**
331 * @since 1.5.3
332 */
333export interface UnknownArrayC extends AnyArrayType {
334}
335/**
336 * @since 1.7.1
337 */
338export declare const UnknownArray: UnknownArrayC;
339/**
340 * @since 1.0.0
341 */
342export declare class AnyDictionaryType extends Type<{
343 [key: string]: unknown;
344}> {
345 /**
346 * @since 1.0.0
347 */
348 readonly _tag: 'AnyDictionaryType';
349 constructor();
350}
351/**
352 * @since 1.7.1
353 */
354export declare const UnknownRecord: UnknownRecordC;
355/**
356 * @since 1.5.3
357 */
358export interface UnknownRecordC extends AnyDictionaryType {
359}
360/**
361 * @since 1.0.0
362 * @deprecated
363 */
364export declare class FunctionType extends Type<Function> {
365 /**
366 * @since 1.0.0
367 */
368 readonly _tag: 'FunctionType';
369 constructor();
370}
371/**
372 * @since 1.5.3
373 * @deprecated
374 */
375export interface FunctionC extends FunctionType {
376}
377/**
378 * @since 1.0.0
379 * @deprecated
380 */
381export declare const Function: FunctionC;
382/**
383 * @since 1.0.0
384 */
385export declare class RefinementType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
386 readonly type: C;
387 readonly predicate: Predicate<A>;
388 /**
389 * @since 1.0.0
390 */
391 readonly _tag: 'RefinementType';
392 constructor(name: string, is: RefinementType<C, A, O, I>['is'], validate: RefinementType<C, A, O, I>['validate'], encode: RefinementType<C, A, O, I>['encode'], type: C, predicate: Predicate<A>);
393}
394declare const _brand: unique symbol;
395/**
396 * @since 1.8.1
397 */
398export interface Brand<B> {
399 readonly [_brand]: B;
400}
401/**
402 * @since 1.8.1
403 */
404export declare type Branded<A, B> = A & Brand<B>;
405/**
406 * @since 1.8.1
407 */
408export interface BrandC<C extends Any, B> extends RefinementType<C, Branded<TypeOf<C>, B>, OutputOf<C>, InputOf<C>> {
409}
410/**
411 * @since 1.8.1
412 */
413export declare const brand: <C extends Any, N extends string, B extends { readonly [K in N]: symbol; }>(codec: C, predicate: Refinement<C["_A"], Branded<C["_A"], B>>, name: N) => BrandC<C, B>;
414/**
415 * @since 1.8.1
416 */
417export interface IntBrand {
418 readonly Int: unique symbol;
419}
420/**
421 * A branded codec representing an integer
422 * @since 1.8.1
423 */
424export declare const Int: BrandC<NumberC, IntBrand>;
425/**
426 * @since 1.8.1
427 */
428export declare type Int = Branded<number, IntBrand>;
429declare type LiteralValue = string | number | boolean;
430/**
431 * @since 1.0.0
432 */
433export declare class LiteralType<V extends LiteralValue> extends Type<V> {
434 readonly value: V;
435 /**
436 * @since 1.0.0
437 */
438 readonly _tag: 'LiteralType';
439 constructor(name: string, is: LiteralType<V>['is'], validate: LiteralType<V>['validate'], encode: LiteralType<V>['encode'], value: V);
440}
441/**
442 * @since 1.5.3
443 */
444export interface LiteralC<V extends LiteralValue> extends LiteralType<V> {
445}
446/**
447 * @since 1.0.0
448 */
449export declare const literal: <V extends string | number | boolean>(value: V, name?: string) => LiteralC<V>;
450/**
451 * @since 1.0.0
452 */
453export declare class KeyofType<D extends {
454 [key: string]: unknown;
455}> extends Type<keyof D> {
456 readonly keys: D;
457 /**
458 * @since 1.0.0
459 */
460 readonly _tag: 'KeyofType';
461 constructor(name: string, is: KeyofType<D>['is'], validate: KeyofType<D>['validate'], encode: KeyofType<D>['encode'], keys: D);
462}
463/**
464 * @since 1.5.3
465 */
466export interface KeyofC<D extends {
467 [key: string]: unknown;
468}> extends KeyofType<D> {
469}
470/**
471 * @since 1.0.0
472 */
473export declare const keyof: <D extends {
474 [key: string]: unknown;
475}>(keys: D, name?: string) => KeyofC<D>;
476/**
477 * @since 1.0.0
478 */
479export declare class RecursiveType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
480 runDefinition: () => C;
481 /**
482 * @since 1.0.0
483 */
484 readonly _tag: 'RecursiveType';
485 constructor(name: string, is: RecursiveType<C, A, O, I>['is'], validate: RecursiveType<C, A, O, I>['validate'], encode: RecursiveType<C, A, O, I>['encode'], runDefinition: () => C);
486 /**
487 * @since 1.0.0
488 */
489 readonly type: C;
490}
491/**
492 * @since 1.0.0
493 */
494export declare const 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>;
495/**
496 * @since 1.0.0
497 */
498export declare class ArrayType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
499 readonly type: C;
500 /**
501 * @since 1.0.0
502 */
503 readonly _tag: 'ArrayType';
504 constructor(name: string, is: ArrayType<C, A, O, I>['is'], validate: ArrayType<C, A, O, I>['validate'], encode: ArrayType<C, A, O, I>['encode'], type: C);
505}
506/**
507 * @since 1.5.3
508 */
509export interface ArrayC<C extends Mixed> extends ArrayType<C, Array<TypeOf<C>>, Array<OutputOf<C>>, unknown> {
510}
511/**
512 * @since 1.0.0
513 */
514export declare const array: <C extends Mixed>(codec: C, name?: string) => ArrayC<C>;
515/**
516 * @since 1.0.0
517 */
518export declare class InterfaceType<P, A = any, O = A, I = unknown> extends Type<A, O, I> {
519 readonly props: P;
520 /**
521 * @since 1.0.0
522 */
523 readonly _tag: 'InterfaceType';
524 constructor(name: string, is: InterfaceType<P, A, O, I>['is'], validate: InterfaceType<P, A, O, I>['validate'], encode: InterfaceType<P, A, O, I>['encode'], props: P);
525}
526/**
527 * @since 1.0.0
528 */
529export interface AnyProps {
530 [key: string]: Any;
531}
532/**
533 * @since 1.0.0
534 */
535export declare type TypeOfProps<P extends AnyProps> = {
536 [K in keyof P]: TypeOf<P[K]>;
537};
538/**
539 * @since 1.0.0
540 */
541export declare type OutputOfProps<P extends AnyProps> = {
542 [K in keyof P]: OutputOf<P[K]>;
543};
544/**
545 * @since 1.0.0
546 */
547export interface Props {
548 [key: string]: Mixed;
549}
550/**
551 * @since 1.5.3
552 */
553export interface TypeC<P extends Props> extends InterfaceType<P, {
554 [K in keyof P]: TypeOf<P[K]>;
555}, {
556 [K in keyof P]: OutputOf<P[K]>;
557}, unknown> {
558}
559/**
560 * @since 1.0.0
561 */
562export declare const type: <P extends Props>(props: P, name?: string) => TypeC<P>;
563/**
564 * @since 1.0.0
565 */
566export declare class PartialType<P, A = any, O = A, I = unknown> extends Type<A, O, I> {
567 readonly props: P;
568 /**
569 * @since 1.0.0
570 */
571 readonly _tag: 'PartialType';
572 constructor(name: string, is: PartialType<P, A, O, I>['is'], validate: PartialType<P, A, O, I>['validate'], encode: PartialType<P, A, O, I>['encode'], props: P);
573}
574/**
575 * @since 1.0.0
576 */
577export declare type TypeOfPartialProps<P extends AnyProps> = {
578 [K in keyof P]?: TypeOf<P[K]>;
579};
580/**
581 * @since 1.0.0
582 */
583export declare type OutputOfPartialProps<P extends AnyProps> = {
584 [K in keyof P]?: OutputOf<P[K]>;
585};
586/**
587 * @since 1.5.3
588 */
589export interface PartialC<P extends Props> extends PartialType<P, {
590 [K in keyof P]?: TypeOf<P[K]>;
591}, {
592 [K in keyof P]?: OutputOf<P[K]>;
593}, unknown> {
594}
595/**
596 * @since 1.0.0
597 */
598export declare const partial: <P extends Props>(props: P, name?: string) => PartialC<P>;
599/**
600 * @since 1.0.0
601 */
602export declare class DictionaryType<D extends Any, C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
603 readonly domain: D;
604 readonly codomain: C;
605 /**
606 * @since 1.0.0
607 */
608 readonly _tag: 'DictionaryType';
609 constructor(name: string, is: DictionaryType<D, C, A, O, I>['is'], validate: DictionaryType<D, C, A, O, I>['validate'], encode: DictionaryType<D, C, A, O, I>['encode'], domain: D, codomain: C);
610}
611/**
612 * @since 1.0.0
613 */
614export declare type TypeOfDictionary<D extends Any, C extends Any> = {
615 [K in TypeOf<D>]: TypeOf<C>;
616};
617/**
618 * @since 1.0.0
619 */
620export declare type OutputOfDictionary<D extends Any, C extends Any> = {
621 [K in OutputOf<D>]: OutputOf<C>;
622};
623/**
624 * @since 1.5.3
625 */
626export interface RecordC<D extends Mixed, C extends Mixed> extends DictionaryType<D, C, {
627 [K in TypeOf<D>]: TypeOf<C>;
628}, {
629 [K in OutputOf<D>]: OutputOf<C>;
630}, unknown> {
631}
632/**
633 * @since 1.7.1
634 */
635export declare function record<D extends Mixed, C extends Mixed>(domain: D, codomain: C, name?: string): RecordC<D, C>;
636/**
637 * @since 1.0.0
638 */
639export declare class UnionType<CS extends Array<Any>, A = any, O = A, I = unknown> extends Type<A, O, I> {
640 readonly types: CS;
641 /**
642 * @since 1.0.0
643 */
644 readonly _tag: 'UnionType';
645 constructor(name: string, is: UnionType<CS, A, O, I>['is'], validate: UnionType<CS, A, O, I>['validate'], encode: UnionType<CS, A, O, I>['encode'], types: CS);
646}
647/**
648 * @since 1.5.3
649 */
650export interface UnionC<CS extends [Mixed, Mixed, ...Array<Mixed>]> extends UnionType<CS, TypeOf<CS[number]>, OutputOf<CS[number]>, unknown> {
651}
652/**
653 * @since 1.0.0
654 */
655export declare const union: <CS extends [Mixed, Mixed, ...Mixed[]]>(codecs: CS, name?: string) => UnionC<CS>;
656/**
657 * @since 1.0.0
658 */
659export declare class IntersectionType<CS extends Array<Any>, A = any, O = A, I = unknown> extends Type<A, O, I> {
660 readonly types: CS;
661 /**
662 * @since 1.0.0
663 */
664 readonly _tag: 'IntersectionType';
665 constructor(name: string, is: IntersectionType<CS, A, O, I>['is'], validate: IntersectionType<CS, A, O, I>['validate'], encode: IntersectionType<CS, A, O, I>['encode'], types: CS);
666}
667/**
668 * @since 1.5.3
669 */
670export interface IntersectionC<CS extends [Mixed, Mixed, ...Array<Mixed>]> extends IntersectionType<CS, CS extends {
671 length: 2;
672} ? TypeOf<CS[0]> & TypeOf<CS[1]> : CS extends {
673 length: 3;
674} ? TypeOf<CS[0]> & TypeOf<CS[1]> & TypeOf<CS[2]> : CS extends {
675 length: 4;
676} ? TypeOf<CS[0]> & TypeOf<CS[1]> & TypeOf<CS[2]> & TypeOf<CS[3]> : CS extends {
677 length: 5;
678} ? TypeOf<CS[0]> & TypeOf<CS[1]> & TypeOf<CS[2]> & TypeOf<CS[3]> & TypeOf<CS[4]> : unknown, CS extends {
679 length: 2;
680} ? OutputOf<CS[0]> & OutputOf<CS[1]> : CS extends {
681 length: 3;
682} ? OutputOf<CS[0]> & OutputOf<CS[1]> & OutputOf<CS[2]> : CS extends {
683 length: 4;
684} ? OutputOf<CS[0]> & OutputOf<CS[1]> & OutputOf<CS[2]> & OutputOf<CS[3]> : CS extends {
685 length: 5;
686} ? OutputOf<CS[0]> & OutputOf<CS[1]> & OutputOf<CS[2]> & OutputOf<CS[3]> & OutputOf<CS[4]> : unknown, unknown> {
687}
688/**
689 * @since 1.0.0
690 */
691export declare function 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]>;
692export declare function intersection<A extends Mixed, B extends Mixed, C extends Mixed, D extends Mixed>(codecs: [A, B, C, D], name?: string): IntersectionC<[A, B, C, D]>;
693export declare function intersection<A extends Mixed, B extends Mixed, C extends Mixed>(codecs: [A, B, C], name?: string): IntersectionC<[A, B, C]>;
694export declare function intersection<A extends Mixed, B extends Mixed>(codecs: [A, B], name?: string): IntersectionC<[A, B]>;
695/**
696 * @since 1.0.0
697 */
698export declare class TupleType<CS extends Array<Any>, A = any, O = A, I = unknown> extends Type<A, O, I> {
699 readonly types: CS;
700 /**
701 * @since 1.0.0
702 */
703 readonly _tag: 'TupleType';
704 constructor(name: string, is: TupleType<CS, A, O, I>['is'], validate: TupleType<CS, A, O, I>['validate'], encode: TupleType<CS, A, O, I>['encode'], types: CS);
705}
706/**
707 * @since 1.5.3
708 */
709export interface TupleC<CS extends [Mixed, ...Array<Mixed>]> extends TupleType<CS, CS extends {
710 length: 1;
711} ? [TypeOf<CS[0]>] : CS extends {
712 length: 2;
713} ? [TypeOf<CS[0]>, TypeOf<CS[1]>] : CS extends {
714 length: 3;
715} ? [TypeOf<CS[0]>, TypeOf<CS[1]>, TypeOf<CS[2]>] : CS extends {
716 length: 4;
717} ? [TypeOf<CS[0]>, TypeOf<CS[1]>, TypeOf<CS[2]>, TypeOf<CS[3]>] : CS extends {
718 length: 5;
719} ? [TypeOf<CS[0]>, TypeOf<CS[1]>, TypeOf<CS[2]>, TypeOf<CS[3]>, TypeOf<CS[4]>] : unknown, CS extends {
720 length: 1;
721} ? [OutputOf<CS[0]>] : CS extends {
722 length: 2;
723} ? [OutputOf<CS[0]>, OutputOf<CS[1]>] : CS extends {
724 length: 3;
725} ? [OutputOf<CS[0]>, OutputOf<CS[1]>, OutputOf<CS[2]>] : CS extends {
726 length: 4;
727} ? [OutputOf<CS[0]>, OutputOf<CS[1]>, OutputOf<CS[2]>, OutputOf<CS[3]>] : CS extends {
728 length: 5;
729} ? [OutputOf<CS[0]>, OutputOf<CS[1]>, OutputOf<CS[2]>, OutputOf<CS[3]>, OutputOf<CS[4]>] : unknown, unknown> {
730}
731/**
732 * @since 1.0.0
733 */
734export declare function 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]>;
735export declare function tuple<A extends Mixed, B extends Mixed, C extends Mixed, D extends Mixed>(codecs: [A, B, C, D], name?: string): TupleC<[A, B, C, D]>;
736export declare function tuple<A extends Mixed, B extends Mixed, C extends Mixed>(codecs: [A, B, C], name?: string): TupleC<[A, B, C]>;
737export declare function tuple<A extends Mixed, B extends Mixed>(codecs: [A, B], name?: string): TupleC<[A, B]>;
738export declare function tuple<A extends Mixed>(codecs: [A], name?: string): TupleC<[A]>;
739/**
740 * @since 1.0.0
741 */
742export declare class ReadonlyType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
743 readonly type: C;
744 /**
745 * @since 1.0.0
746 */
747 readonly _tag: 'ReadonlyType';
748 constructor(name: string, is: ReadonlyType<C, A, O, I>['is'], validate: ReadonlyType<C, A, O, I>['validate'], encode: ReadonlyType<C, A, O, I>['encode'], type: C);
749}
750/**
751 * @since 1.5.3
752 */
753export interface ReadonlyC<C extends Mixed> extends ReadonlyType<C, Readonly<TypeOf<C>>, Readonly<OutputOf<C>>, unknown> {
754}
755/**
756 * @since 1.0.0
757 */
758export declare const readonly: <C extends Mixed>(codec: C, name?: string) => ReadonlyC<C>;
759/**
760 * @since 1.0.0
761 */
762export declare class ReadonlyArrayType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
763 readonly type: C;
764 /**
765 * @since 1.0.0
766 */
767 readonly _tag: 'ReadonlyArrayType';
768 constructor(name: string, is: ReadonlyArrayType<C, A, O, I>['is'], validate: ReadonlyArrayType<C, A, O, I>['validate'], encode: ReadonlyArrayType<C, A, O, I>['encode'], type: C);
769}
770/**
771 * @since 1.5.3
772 */
773export interface ReadonlyArrayC<C extends Mixed> extends ReadonlyArrayType<C, ReadonlyArray<TypeOf<C>>, ReadonlyArray<OutputOf<C>>, unknown> {
774}
775/**
776 * @since 1.0.0
777 */
778export declare const readonlyArray: <C extends Mixed>(codec: C, name?: string) => ReadonlyArrayC<C>;
779/**
780 * Strips additional properties
781 * @since 1.0.0
782 */
783export declare const strict: <P extends Props>(props: P, name?: string | undefined) => ExactC<TypeC<P>>;
784/**
785 * @since 1.3.0
786 * @deprecated
787 */
788export declare class TaggedUnionType<Tag extends string, CS extends Array<Mixed>, A = any, O = A, I = unknown> extends UnionType<CS, A, O, I> {
789 readonly tag: Tag;
790 constructor(name: string, is: TaggedUnionType<Tag, CS, A, O, I>['is'], validate: TaggedUnionType<Tag, CS, A, O, I>['validate'], encode: TaggedUnionType<Tag, CS, A, O, I>['encode'], codecs: CS, tag: Tag);
791}
792/**
793 * @since 1.5.3
794 * @deprecated
795 */
796export interface TaggedUnionC<Tag extends string, CS extends [Mixed, Mixed, ...Array<Mixed>]>// tslint:disable-next-line: deprecation
797 extends TaggedUnionType<Tag, CS, TypeOf<CS[number]>, OutputOf<CS[number]>, unknown> {
798}
799/**
800 * Use `union` instead
801 *
802 * @since 1.3.0
803 * @deprecated
804 */
805export declare const taggedUnion: <Tag extends string, CS extends [Mixed, Mixed, ...Mixed[]]>(tag: Tag, codecs: CS, name?: string) => TaggedUnionC<Tag, CS>;
806/**
807 * @since 1.1.0
808 */
809export declare class ExactType<C extends Any, A = any, O = A, I = unknown> extends Type<A, O, I> {
810 readonly type: C;
811 /**
812 * @since 1.0.0
813 */
814 readonly _tag: 'ExactType';
815 constructor(name: string, is: ExactType<C, A, O, I>['is'], validate: ExactType<C, A, O, I>['validate'], encode: ExactType<C, A, O, I>['encode'], type: C);
816}
817/**
818 * @since 1.1.0
819 */
820export interface HasPropsRefinement extends RefinementType<HasProps, any, any, any> {
821}
822/**
823 * @since 1.1.0
824 */
825export interface HasPropsReadonly extends ReadonlyType<HasProps, any, any, any> {
826}
827/**
828 * @since 1.1.0
829 */
830export interface HasPropsIntersection extends IntersectionType<Array<HasProps>, any, any, any> {
831}
832/**
833 * @since 1.1.0
834 */
835export declare type HasProps = HasPropsRefinement | HasPropsReadonly | HasPropsIntersection | InterfaceType<any, any, any, any> | StrictType<any, any, any, any> | PartialType<any, any, any, any>;
836/**
837 * @since 1.5.3
838 */
839export interface ExactC<C extends HasProps> extends ExactType<C, TypeOf<C>, OutputOf<C>, InputOf<C>> {
840}
841/**
842 * Strips additional properties
843 * @since 1.1.0
844 */
845export declare const exact: <C extends HasProps>(codec: C, name?: string) => ExactC<C>;
846export {
847/**
848 * @since 1.0.0
849 */
850nullType as null };
851export {
852/**
853 * @since 1.0.0
854 */
855undefinedType as undefined };
856export {
857/**
858 * Use `UnknownArray` instead
859 * @deprecated
860 * @since 1.0.0
861 */
862UnknownArray as Array };
863export {
864/**
865 * Use `type` instead
866 * @deprecated
867 * @since 1.0.0
868 */
869type as interface };
870export {
871/**
872 * @since 1.0.0
873 */
874voidType as void };
875/**
876 * Use `unknown` instead
877 * @since 1.0.0
878 * @deprecated
879 */
880export declare type mixed = unknown;
881/**
882 * @since 1.0.0
883 * @deprecated
884 */
885export declare const getValidationError: (value: unknown, context: Context) => ValidationError;
886/**
887 * @since 1.0.0
888 * @deprecated
889 */
890export declare const getDefaultContext: (decoder: Decoder<any, any>) => Context;
891/**
892 * @since 1.0.0
893 * @deprecated
894 */
895export declare class NeverType extends Type<never> {
896 /**
897 * @since 1.0.0
898 */
899 readonly _tag: 'NeverType';
900 constructor();
901}
902/**
903 * @since 1.5.3
904 * @deprecated
905 */
906export interface NeverC extends NeverType {
907}
908/**
909 * @since 1.0.0
910 * @deprecated
911 */
912export declare const never: NeverC;
913/**
914 * @since 1.0.0
915 * @deprecated
916 */
917export declare class AnyType extends Type<any> {
918 /**
919 * @since 1.0.0
920 */
921 readonly _tag: 'AnyType';
922 constructor();
923}
924/**
925 * @since 1.5.3
926 * @deprecated
927 */
928export interface AnyC extends AnyType {
929}
930/**
931 * Use `unknown` instead
932 * @since 1.0.0
933 * @deprecated
934 */
935export declare const any: AnyC;
936/**
937 * Use `UnknownRecord` instead
938 * @since 1.0.0
939 * @deprecated
940 */
941export declare const Dictionary: UnknownRecordC;
942/**
943 * @since 1.0.0
944 * @deprecated
945 */
946export declare class ObjectType extends Type<object> {
947 /**
948 * @since 1.0.0
949 */
950 readonly _tag: 'ObjectType';
951 constructor();
952}
953/**
954 * @since 1.5.3
955 * @deprecated
956 */
957export interface ObjectC extends ObjectType {
958}
959/**
960 * Use `UnknownRecord` instead
961 * @since 1.0.0
962 * @deprecated
963 */
964export declare const object: ObjectC;
965/**
966 * Use `BrandC` instead
967 * @since 1.5.3
968 * @deprecated
969 */
970export interface RefinementC<C extends Any> extends RefinementType<C, TypeOf<C>, OutputOf<C>, InputOf<C>> {
971}
972/**
973 * Use `brand` instead
974 * @since 1.0.0
975 * @deprecated
976 */
977export declare function refinement<C extends Any>(codec: C, predicate: Predicate<TypeOf<C>>, name?: string): RefinementC<C>;
978/**
979 * Use `Int` instead
980 * @since 1.0.0
981 * @deprecated
982 */
983export declare const Integer: RefinementC<NumberC>;
984/**
985 * Use `record` instead
986 * @since 1.0.0
987 * @deprecated
988 */
989export declare const dictionary: typeof record;
990/**
991 * used in `intersection` as a workaround for #234
992 * @since 1.4.2
993 * @deprecated
994 */
995export declare type Compact<A> = {
996 [K in keyof A]: A[K];
997};
998/**
999 * @since 1.0.0
1000 * @deprecated
1001 */
1002export declare class StrictType<P, A = any, O = A, I = unknown> extends Type<A, O, I> {
1003 readonly props: P;
1004 /**
1005 * @since 1.0.0
1006 */
1007 readonly _tag: 'StrictType';
1008 constructor(name: string, is: StrictType<P, A, O, I>['is'], validate: StrictType<P, A, O, I>['validate'], encode: StrictType<P, A, O, I>['encode'], props: P);
1009}
1010/**
1011 * @since 1.5.3
1012 * @deprecated
1013 */
1014export interface StrictC<P extends Props>// tslint:disable-next-line: deprecation
1015 extends StrictType<P, {
1016 [K in keyof P]: TypeOf<P[K]>;
1017}, {
1018 [K in keyof P]: OutputOf<P[K]>;
1019}, unknown> {
1020}
1021/**
1022 * @since 1.3.0
1023 * @deprecated
1024 */
1025export declare type TaggedProps<Tag extends string> = {
1026 [K in Tag]: LiteralType<any>;
1027};
1028/**
1029 * @since 1.3.0
1030 * @deprecated
1031 */
1032export interface TaggedRefinement<Tag extends string, A, O = A> extends RefinementType<Tagged<Tag>, A, O> {
1033}
1034/**
1035 * @since 1.3.0
1036 * @deprecated
1037 */
1038export interface TaggedUnion<Tag extends string, A, O = A> extends UnionType<Array<Tagged<Tag>>, A, O> {
1039}
1040/**
1041 * @since 1.3.0
1042 * @deprecated
1043 */
1044export declare 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>];
1045/**
1046 * @since 1.3.0
1047 * @deprecated
1048 */
1049export interface TaggedIntersection<Tag extends string, A, O = A>// tslint:disable-next-line: deprecation
1050 extends IntersectionType<TaggedIntersectionArgument<Tag>, A, O> {
1051}
1052/**
1053 * @since 1.3.0
1054 * @deprecated
1055 */
1056export interface TaggedExact<Tag extends string, A, O = A> extends ExactType<Tagged<Tag>, A, O> {
1057}
1058/**
1059 * @since 1.3.0
1060 * @deprecated
1061 */
1062export declare 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>;
1063/**
1064 * Drops the codec "kind"
1065 * @since 1.1.0
1066 * @deprecated
1067 */
1068export declare function clean<A, O = A, I = unknown>(codec: Type<A, O, I>): Type<A, O, I>;
1069/**
1070 * @since 1.0.0
1071 * @deprecated
1072 */
1073export declare type PropsOf<T extends {
1074 props: any;
1075}> = T['props'];
1076/**
1077 * @since 1.1.0
1078 * @deprecated
1079 */
1080export declare type Exact<T, X extends T> = T & {
1081 [K in ({
1082 [K in keyof X]: K;
1083 } & {
1084 [K in keyof T]: never;
1085 } & {
1086 [key: string]: never;
1087 })[keyof X]]?: never;
1088};
1089/**
1090 * Keeps the codec "kind"
1091 * @since 1.1.0
1092 * @deprecated
1093 */
1094export declare function alias<A, O, P, I>(codec: PartialType<P, A, O, I>): <AA extends Exact<A, AA>, OO extends Exact<O, OO> = O, PP extends Exact<P, PP> = P, II extends I = I>() => PartialType<PP, AA, OO, II>;
1095export declare function alias<A, O, P, I>(codec: StrictType<P, A, O, I>): <AA extends Exact<A, AA>, OO extends Exact<O, OO> = O, PP extends Exact<P, PP> = P, II extends I = I>() => StrictType<PP, AA, OO, II>;
1096export declare function alias<A, O, P, I>(codec: InterfaceType<P, A, O, I>): <AA extends Exact<A, AA>, OO extends Exact<O, OO> = O, PP extends Exact<P, PP> = P, II extends I = I>() => InterfaceType<PP, AA, OO, II>;