const schema = {
name: { type: "string" },
age: { type: "number", nullable: true },
status: { type: "enum", values: ["active", "inactive"] },
tags: { type: "array", items: { type: "string" } },
geo: { type: "object", fields: { lat: { type: "number" }, lng: { type: "number" } } }
} as const satisfies ObjectSchema;
type MyType = InferObjectSchema<typeof schema>;
// {
// name: string;
// status: "active" | "inactive";
// tags: string[];
// geo: { lat: number; lng: number };
// age?: number | null;
// }
Infers the TypeScript type from an ObjectSchema definition.
values(values[number])InferObjectSchemaT[]whereTis inferred fromitemsnullable: truebecome optional and acceptnull(T | null | undefined)