/** * @file HigherKind.Types.ts * @author Gage Sorrell * @copyright (c) 2026 Gage Sorrell * @license MIT */ /** The type that all function types extend. */ export type AnyFunction = (...ArgumentVector: Array) => unknown; /** * Define {@link https://en.wikipedia.org/wiki/Kind_(type_theory) | higher-kinded types } * by extending this class (see the example below). * * @template ArgumentVectorType - The `readonly` tuple-type that defines the type parameter * signature of the resulting generic type. Please note that the `readonly` keyword *must* * be used when defining a higher-kind type with this. * * @example Map a tuple-type to a union of its element types. * ```typescript * interface TupleToUnion extends HigherKind> * { * new: () => this["ArgumentVector"][number]; * } * * type A = Apply; * // ^? string | number | boolean * ``` * * @example A constrained higher-kinded type. * ```typescript * interface FooWithNumberTail extends HigherKind> * { * new: () => this["ArgumentVector"]; * } * * // ✓ Good * type A = Apply; * // ^? [ "Foo" ] * * // ✓ Good * type B = Apply; * // ^? [ "Foo", 1, 2, 3 ] * * // (To define the constants below) * type C = Apply; * * // ✓ Good * const Bar: C = [ "Foo", 3, 2 ]; * // ^? [ "Foo", 3, 2 ] * * // ✗ Bad * const Baz: C = [ "Foo", 3, 4, 5 ]; * // ^^^ Error * * // ✗ Bad * type D = Apply; * // ^^^^^^^ Error * ``` */ export declare abstract class HigherKind = ReadonlyArray> { readonly ArgumentVector: ArgumentVectorType; new: AnyFunction; } /** * Get the argument vector type of a given {@link HigherKind | higher-kinded type}. * * * @template HigherKindType - The {@link HigherKind | higher-kinded type} whose * argument vector type will be inferred. */ export type ArgumentsOf> = HigherKindType extends HigherKind ? OutType : never; declare const AssertTupleFailure: unique symbol; export type AssertTuple, RightType extends ReadonlyArray> = typeof AssertTupleFailure extends ({ [Index in number]: LeftType[Index] extends RightType[Index] ? LeftType[Index] : typeof AssertTupleFailure; }[number]) ? never : LeftType; /** * Define a type from a {@link HigherKind | higher-kinded type}, optionally * with a constrained {@link ArgumentVectorType}. * * @see {@link HigherKind} * * @template HigherKindType - The {@link | higher-kinded type} to apply. * @template ArgumentVectorType - The type parameter vector that is passed to * the given {@link HigherKindType}. */ export type Apply>, ArgumentVectorType extends ArgumentsOf = ArgumentsOf> = ReturnType<(HigherKindType & { readonly ArgumentVector: ArgumentVectorType; })["new"]>; export {}; //# sourceMappingURL=HigherKind.Types.d.cts.map