Libraries (v1.1.10)
    Preparing search index...

    Type Alias InferType<T>

    InferType: T extends SchemaBuilder<infer TResult, infer TRequired>
        ? T extends {
            optimize: (
                ...args: any[],
            ) => SchemaBuilder<infer TOptimizedType, infer TOptimizedRequired>;
        }
            ? TOptimizedRequired extends true
                ? TOptimizedType
                : MakeOptional<TOptimizedType>
            : TRequired extends true ? TResult : MakeOptional<TResult>
        : T

    Infers the TypeScript type that a SchemaBuilder instance validates. Takes into account type optimizations (via optimize()) and whether the schema is optional.

    Type Parameters

    • T
    const userSchema = object({ name: string(), age: number().optional() });
    type User = InferType<typeof userSchema>;
    // { name: string; age?: number }