Skip to main content

Type Alias: InferType<T>

InferType<T>: T extends ObjectValidator<any, infer U> ? U : never

Infers the type of a schema object given typeof schema. The schema has to extend ObjectValidator.

Type Parameters

Type Parameter
T extends ObjectValidator<any>

Example

import { InferType, s } from '@sapphire/shapeshift';

const schema = s.object({
foo: s.string,
bar: s.number,
baz: s.boolean,
qux: s.bigint,
quux: s.date
});

type Inferredtype = InferType<typeof schema>;
// Expected type:
// type Inferredtype = {
// foo: string;
// bar: number;
// baz: boolean;
// qux: bigint;
// quux: Date;
// };

Defined in

projects/shapeshift/src/lib/util-types.ts:114