import { Result } from "../result"; import { TypedKind } from "../kind"; import { Comment, Either, Intersection, Projection, Type, TypeImpl } 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; }; type ObjectField = { readonly checker: TypedKind; readonly allowsMissing: boolean; }; type ObjectFields = { [key: string]: ObjectField; [key: symbol]: ObjectField; }; type ObjectShape = { readonly fields: ObjectFields; readonly exact: boolean; readonly requirePlainObject: boolean; readonly rest?: TypedKind; }; export type MissingIssue = { readonly kind: "missing"; readonly subject: "object"; }; export type UnknownPropertyIssue = { readonly kind: "unknown-property"; readonly subject: "object"; }; declare abstract class MergeableType extends TypeImpl { private readonly objectShape; constructor(objectShape: ObjectShape); check(val: any): Result; sliceResult(val: any): Result; protected merge(type: TypedKind): TypedKind | undefined; protected project(val: any): Projection; } export declare class Dict extends MergeableType> { readonly namedKey: string; readonly valueType: TypedKind; constructor(v: Type, namedKey?: string); keyName(key: string): Dict; } export declare function dict(v: Type): Dict; export type FieldDef = Type | MissingKey | OptionalKey; export type TypeStruct = { [key: string]: FieldDef; [key: symbol]: 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 | T): T; 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); } 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 hiddenTypeStruct; constructor(struct: Struct); reify(): Struct>; } export declare function deepPartial(ogstruct: Struct): PartialStruct>; type ObjectOperand = Dict | Struct | PartialStruct; type MergeableKind = ObjectOperand | MergeIntersect; export declare class MergeIntersect extends MergeableType { readonly operands: ReadonlyArray; constructor(operands: ReadonlyArray); } export declare const Nested: readonly [typeof Struct, typeof PartialStruct, typeof Dict, typeof Either, typeof Intersection, typeof MergeIntersect, typeof Comment]; export type NestedType = InstanceType<(typeof Nested)[number]>; export declare function partial(struct: Struct): PartialStruct; export {};