UNPKG

rivo

Version:

🤖 The ultimate library you need for composable type-level programming in TypeScript, powered by HKT.

41 lines (37 loc) • 1.13 kB
// @ts-ignore - Only used in doc comments import type { List } from "."; import type { Args, GenericFn, GenericResolver } from ".."; // @ts-ignore - Only used in doc comments import type { Of1 } from "../Tuple/Of1"; // @ts-ignore - Only used in doc comments import type Of1Fn from "../Tuple/Of1"; import type { Broaden } from "../helpers"; /** * Create a {@link List} with one element. * * Sig: `<T>(x: T) => List<T>` * * @example * ```typescript * type R1 = Create<1>; * // ^?: readonly [1] * type R2 = Create<"foo" | false>; * // ^?: readonly ["foo" | false] * ``` * * @see {@link Of1} if you want a version with more precise function signature. */ export type Create<T> = readonly [T]; interface Resolver extends GenericResolver<[unknown], List<unknown>> { on1: ([x]: Args<this>) => [[], List<Broaden<typeof x>>]; } /** * [Fn] Create a {@link List} with one element. * * Sig: `<T>(x: T) => List<T>` * * @see {@link Of1Fn} if you want a version with more precise function signature. */ export default interface CreateFn extends GenericFn<Resolver> { def: ([x]: Args<this>) => Create<typeof x>; }