Libraries
    Preparing search index...

    Type Alias InferFromJsonSchema<S>

    InferFromJsonSchema: S extends { const: infer V }
        ? V
        : S extends { enum: readonly (infer V)[] }
            ? V
            : S extends { type: "string" }
                ? string
                : S extends { type: "number"
                | "integer" }
                    ? number
                    : S extends { type: "boolean" }
                        ? boolean
                        : S extends { type: "null" }
                            ? null
                            : S extends { items: infer I; type: "array" }
                                ? InferFromJsonSchema<I>[]
                                : S extends { type: "array" }
                                    ? unknown[]
                                    : S extends {
                                        properties: infer P;
                                        required: readonly (...);
                                        type: "object";
                                    }
                                        ? { [K in (...) as (...)]: (...) } & {
                                            [K in (...) as (...)]?: (...)
                                        }
                                        : S extends { properties: ...; type: ... }
                                            ? { [K in (...)]?: (...) }
                                            : (...) extends (...) ? (...) : (...)

    Recursively infers a TypeScript type from a statically-known JSON Schema node.

    Requires as const on the input object for precise inference — without it TypeScript widens string literals to string and inference collapses to unknown.

    Type Parameters

    • S
    type User = InferFromJsonSchema<typeof UserJsonSchema>;
    // { name: string; age?: number }