UNPKG

rivo

Version:

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

31 lines (27 loc) • 757 B
import type { ReadonlyAry } from "."; import type { Args, GenericFn, GenericResolver } from "../HKT"; /** * Build a readonly array from a type. * * Sig: `<T>(x: T) => ReadonlyArray<T>` * * @example * ```typescript * type R1 = OfReadonly<number>; * // ^?: readonly number[] * type R2 = OfReadonly<42>; * // ^?: readonly (42 | string)[] * ``` */ export type OfReadonly<T> = readonly T[]; interface Resolver extends GenericResolver<[unknown], ReadonlyAry<unknown>> { on1: ([x]: Args<this>) => [[], ReadonlyAry<typeof x>]; } /** * [Fn] Build a readonly array from a type. * * Sig: `<T>(x: T) => ReadonlyArray<T>` */ export default interface OfReadonlyFn extends GenericFn<Resolver> { def: ([x]: Args<this>) => OfReadonly<typeof x>; }