import { Result } from "../result"; import { Type, CustomCommutativeAndType, Either, DefaultIntersect, Comment } from "../type"; import { GetType } from "../get-type"; export declare class MissingKey> { readonly type: T; constructor(type: T); } export declare class OptionalKey> { readonly type: T; constructor(type: T); } type WrapperOrType = T extends MissingKey ? Inner : T extends OptionalKey ? Inner : T; type RawDict = { [key: string]: V; }; declare abstract class MergeableType extends CustomCommutativeAndType { and(type: Type): Type; } export declare class Dict extends MergeableType> { readonly namedKey: string; readonly valueType: Type; constructor(v: Type, namedKey?: string); keyName(key: string): Dict; check(val: any): Result>; sliceResult(val: any): Result>; } export declare function dict(v: Type): Dict; export type FieldDef = Type | MissingKey | OptionalKey; export type TypeStruct = { [key: string]: FieldDef; }; type OptionalPropertyNames = { [K in keyof T]: T[K] extends MissingKey ? K : T[K] extends OptionalKey ? K : never; }[keyof T]; type UnwrapTypes = { [K in keyof T]: GetType>; }; export type UnwrappedTypeStruct = Pick, Exclude>> & Partial, OptionalPropertyNames>>; export type TypeStructFor = { [K in keyof T]: Type; }; export type StructFor = Struct>; export declare function keyType(box: MissingKey> | OptionalKey> | Type): Type; export declare function allowsMissing>(box: MissingKey | T): box is MissingKey; export declare function allowsOptional>(box: MissingKey | T): box is OptionalKey; export declare class Struct extends MergeableType> { readonly definition: T; readonly exact: boolean; constructor(definition: T, exact: boolean); check(val: any): Result>; sliceResult(val: any): Result>; private checkType; private checkFields; } export declare function subtype(def: T): Struct; export declare function exact(def: T): Struct; export declare function optional>(check: T): OptionalKey; export declare function allowMissing>(check: T): MissingKey; type MakeOptional = T extends Type ? OptionalKey : T extends MissingKey ? OptionalKey : T; type DeepPartialTypeStruct = { [K in keyof T]: T[K] extends Struct ? OptionalKey>> : MakeOptional; }; type PartialTypeStruct = { [K in keyof T]: MakeOptional; }; export declare class PartialStruct extends MergeableType>> { readonly struct: Struct; private readonly hiddenStruct; private readonly hiddenTypeStruct; constructor(struct: Struct); check(val: any): Result>>; sliceResult(val: any): Result>>; reify(): Struct>; } export declare function deepPartial(ogstruct: Struct): PartialStruct>; export declare class MergeIntersect, R extends MergeableType> extends MergeableType { readonly l: L; readonly r: R; protected readonly merged: Type; constructor(l: L, r: R); check(val: any): Result; sliceResult(val: any): Result; private mergeDictAndMergeable; private mergeStructAndMergeable; private mergePartialAndMergeable; private mergeIntersectAndMergeable; private mergeInternalAndDict; private mergeInternalAndStruct; private mergeInternalAndIntersect; private mergeInternalAndInternal; private mergeDicts; private mergeDictAndStruct; private mergeStructs; } export declare const Nested: readonly [typeof Struct, typeof PartialStruct, typeof Dict, typeof Either, typeof DefaultIntersect, typeof MergeIntersect, typeof Comment]; export type NestedType = InstanceType<(typeof Nested)[number]>; export declare function partial(struct: Struct): PartialStruct; export {};