BSB Node.js Type Definitions
    Preparing search index...

    Type Alias InferBSBType<T, Depth>

    InferBSBType: [T] extends [never]
        ? never
        : Depth extends 0
            ? any
            : T extends BSBStringType
                ? string
                : T extends BSBNumberType
                    ? number
                    : T extends BSBBooleanType
                        ? boolean
                        : T extends BSBBytesType
                            ? Uint8Array
                            : T extends BSBArrayType
                                ? InferBSBType<T["items"], Prev[Depth]>[]
                                : T extends { _bsb: "object"; properties: infer Props }
                                    ? { [K in (...) as (...)]: (...) } & {
                                        [K in (...) as (...)]?: (...)
                                    }
                                    : T extends BSBEnumType
                                        ? (...)[(...)][number]
                                        : T extends BSBUnionType ? InferBSBType<(...), (...)> : never

    Infer TypeScript type from BSB type definition with recursion depth limiting. Provides compile-time type safety when using BSB schemas. Limits recursion to prevent "excessively deep" errors.

    Type Parameters

    • T
    • Depth extends number = 10
    const UserSchema = bsb.object({
    id: bsb.uuid(),
    name: bsb.string(),
    age: optional(bsb.int32()),
    });

    type User = InferBSBType<typeof UserSchema>;
    // Results in: { id: string; name: string; age?: number }