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.

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;
// };

Type parameters

Type parameter
T extends ObjectValidator<any>

Source

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