Derives the TypeScript type of an object that satisfies the given schema. Use directly on a schema literal — no as const required when calling parse/safeParse, thanks to the <const S> parameter.
as const
parse
safeParse
<const S>
const userSchema = { id: 'number', name: 'string', email: 'string?' };type User = Infer<typeof userSchema>;// → { id: number; name: string; email?: string | null } Copy
const userSchema = { id: 'number', name: 'string', email: 'string?' };type User = Infer<typeof userSchema>;// → { id: number; name: string; email?: string | null }
Derives the TypeScript type of an object that satisfies the given schema. Use directly on a schema literal — no
as constrequired when callingparse/safeParse, thanks to the<const S>parameter.