API reference › @evolu/common › Type › InferType
type InferType<T> = T["Output"];
Defined in: packages/common/src/Type.ts:1606
Extracts the Output of a Type.
Use it to declare a named object Type Output as an interface. TypeScript then preserves the interface name in tooltips and error messages instead of expanding all of its properties.
Example
import {
assertEqual,
assertType,
NonEmptyTrimmedString100,
PositiveInt,
object,
optional,
type InferType,
} from "@evolu/common";
const User = object({
name: NonEmptyTrimmedString100,
age: optional(PositiveInt),
});
interface User extends InferType<typeof User> {}
const user = User.orThrow({ name: "Ada", age: 37 });
assertType<typeof User.Output, typeof user>();
assertEqual(user.name, "Ada");