import { ArrayAssertion } from "../ArrayAssertion"; import { Assertion, Constructor } from "../Assertion"; import { BooleanAssertion } from "../BooleanAssertion"; import { DateAssertion } from "../DateAssertion"; import { type AnyFunction, FunctionAssertion } from "../FunctionAssertion"; import { NumberAssertion } from "../NumberAssertion"; import { ObjectAssertion } from "../ObjectAssertion"; import { StringAssertion } from "../StringAssertion"; import { Struct } from "./types"; export type AssertionFactory> = new (actual: S) => A; /** * Used to instantiate a specific assertion type. * * @typeParam S the type of the factory's value * @typeParam A the type of the assertion factory */ export interface TypeFactory> { /** * Assertion constructor. */ Factory: AssertionFactory; /** * A predicate function to check the type of the factory's value. * * @param value the factory's value */ predicate: (value: unknown) => value is S; /** * The type of this factory. */ typeName: string; } /** * Encapsulates a set of predefined {@link TypeFactory} instances. */ export interface StaticTypeFactories { /** * A `boolean` TypeFactory. */ Boolean: TypeFactory; /** * A `Date` TypeFactory. */ Date: TypeFactory; /** * A `function` TypeFactory. */ Function: TypeFactory>; /** * A `number` TypeFactory. */ Number: TypeFactory; /** * A `string` TypeFactory. */ String: TypeFactory; /** * Creates an array TypeFactory of the given TypeFactory. * * @example * ``` * TypeFactories.array(TypeFactories.String); // a `string[]` factory * TypeFactories.array(TypeFactories.Date); // a `Date[]` factory * ``` * @typeParam T the type of the array * @param innerType the TypeFactory for the array type */ array(innerType?: TypeFactory>): TypeFactory>; /** * Creates a TypeFactory for an instance of the given constructor. * * @example * ``` * class Person { ... } * * TypeFactories.instanceOf(Person); // a `Person` instance factory * TypeFactories.instanceOf(Error); // an `Error` instance factory * ``` * * @typeParam T the type of the instance constructor * @param Type the instance constructor */ instanceOf(Type: Constructor): TypeFactory>; /** * Creates a TypeFactory for a Javascript Object. * * @example * ``` * interface User { * name: string; * age: number; * } * * TypeFactories.object(); // a `User` object factory * ``` * @typeParam T the type of the object */ object(): TypeFactory>; } export declare const TypeFactories: Readonly;