TypeScript Type Inference
Infer exact TypeScript types from schemas using Infer, Output, and Input.
Infer<S> and Output<S>
Infer<typeof schema> (aliased as Output<S>) extracts the final validated and transformed output type:
Schema Definition
import { infer, type Infer, type Output } from "subatom-infer";
const UserSchema = infer.object({
id: infer.uuid(),
count: infer.number().default(0)
});
type User = Infer<typeof UserSchema>;
// { id: string; count: number }Input<S> (Pre-Transform & Coerce)
When defaults, coercions, or transforms are applied, accepted input may differ from output. Use Input<S> to type accepted raw inputs:
Schema Definition
import { type Input } from "subatom-infer";
type RawUserInput = Input<typeof UserSchema>;
// { id: string; count?: number | undefined }DeepReadonly Utilities
Use DeepReadonly<T> or schema.readonly() to recursively freeze types for immutable state managers.
