UNPKG

rivo

Version:

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

40 lines (36 loc) • 1.48 kB
import type { List } from "."; // @ts-ignore - Only used in doc comments import type { Extend } from "./Extend"; // @ts-ignore - Only used in doc comments import type ExtendFn from "./Extend"; // @ts-ignore - Only used in doc comments import type { ExtendLeftW } from "./ExtendLeftW"; // @ts-ignore - Only used in doc comments import type ExtendLeftWFn from "./ExtendLeftW"; import type { Args, GenericFn, GenericResolver } from "../HKT"; /** * Less strict version of {@link Extend}.The **W** suffix (short for **W**idening) means that both * {@link List}s can hold different types. * * Sig: `<T, U>(ys: List<U>, xs: List<T>) => List<T | U>` * * @see {@link ExtendLeftW} for the opposite. */ export type ExtendW<US extends List, TS extends List> = TS extends unknown[] ? [...TS, ...US] : readonly [...TS, ...US]; interface Resolver extends GenericResolver<[List, List], List> { on1_: ([ys]: Args<this>) => [[List], List]; on_1: ([, xs]: Args<this>) => [[List], List]; on11: ([ys, xs]: Args<this>) => [[], List<(typeof xs)[number] | (typeof ys)[number]>]; } /** * [Fn] Less strict version of {@link ExtendFn}.The **W** suffix (short for **W**idening) means that * both {@link List}s can hold different types. * * Sig: `<T, U>(ys: List<U>, xs: List<T>) => List<T | U>` * * @see {@link ExtendLeftWFn} for the opposite. */ export default interface ExtendWFn extends GenericFn<Resolver> { def: ([ys, xs]: Args<this>) => ExtendW<typeof ys, typeof xs>; }