import { Struct } from "@metamask/superstruct"; import type { Infer, ObjectSchema, OmitBy, Optionalize, PickBy, Simplify, AnyStruct } from "@metamask/superstruct"; import type { Equals } from "./types.mjs"; declare const ExactOptionalSymbol: unique symbol; export type ExactOptionalTag = { type: typeof ExactOptionalSymbol; }; /** * Exclude type `Type` from the properties of `Obj`. * * ```ts * type Foo = { a: string | null; b: number }; * type Bar = ExcludeType; * // Bar = { a: string, b: number } * ``` */ export type ExcludeType = { [K in keyof Obj]: Exclude; }; /** * Make optional all properties that have the `ExactOptionalTag` type. * * ```ts * type Foo = { a: string | ExactOptionalTag; b: number}; * type Bar = ExactOptionalize; * // Bar = { a?: string; b: number} * ``` */ export type ExactOptionalize = OmitBy & Partial, ExactOptionalTag>>; /** * Infer a type from an superstruct object schema. */ export type ObjectType = Simplify; }>>>; /** * Change the return type of a superstruct's `object` function to support * exact optional properties. * * @param schema - The object schema. * @returns A struct representing an object with a known set of properties. */ export declare function object(schema: Schema): Struct, Schema>; /** * Change the return type of a superstruct's `type` function to support * exact optional properties. * * @param schema - The object schema. * @returns A struct representing an object with a known set of properties * and ignore unknown properties. */ export declare function type(schema: Schema): Struct, Schema>; /** * Augment a struct to allow exact-optional values. Exact-optional values can * be omitted but cannot be `undefined`. * * ```ts * const foo = object({ bar: exactOptional(string()) }); * type Foo = Infer; * // Foo = { bar?: string } * ``` * * @param struct - The struct to augment. * @returns The augmented struct. */ export declare function exactOptional(struct: Struct): Struct; /** * Assert that a value is valid according to a struct. * * It is similar to superstruct's mask function, but it does not ignore extra * properties. * * @param value - Value to check. * @param struct - Struct to validate the value against. * @param message - Error message to throw if the value is not valid. * @returns The value if it is valid. */ export declare function strictMask(value: unknown, struct: Struct, message?: string): Type; /** * Extracts the type from a struct definition and asserts that it matches the * expected type. If the types do not match, the type `never` is returned. * * @param StructType - The struct type to infer. * @param ExpectedType - The expected type. */ export type InferEquals, ExpectedType> = Equals, ExpectedType> extends true ? Infer : never; /** * Create a custom union struct that uses a `selector` function for choosing * the validation path. * * @param selector - The selector function choosing the struct to validate with. * @returns The `superstruct` struct, which validates that the value satisfies * one of the structs. */ export declare function selectiveUnion AnyStruct>(selector: Selector): Struct>, null>; export {}; //# sourceMappingURL=superstruct.d.mts.map