import { Next } from "./utils"; import { _apply, apply, _Type as Type } from './apply'; type _Type = { type: any; constraints: C; }; type TooManyArgs = 'You can compose up to 10 free types with Pipe'; type WrongArg = 'would be called with wrong argument'; /** Pipe an arguments list or named arguments through a composition of free types * ``` * type Foo = Pipe<[1, 2], $Add, $Next, $Exclaim> // "4!" * ``` * --- * **Note**: Error messages are narrower than they need to be: * ``` * Pipe<['foo'], $Exclain, $Next> * // ~~~~~ * // Type<[number], number>' does not satisfy the constraint 'Type<["foo!"], number> * ``` * Understand it as `Type<[number], number>` would be called with wrong argument `"foo!"`. This inconvenience is required for generic higher order compositions to work properly. */ export type Pipe = never, C extends _ = never, D extends _ = never, E extends _ = never, F extends _ = never, G extends _ = never, H extends _ = never, I extends _ = never, J extends _ = never, STOP = never, RA = apply, RB = _apply, RC = _apply, RD = _apply, RE = _apply, RF = _apply, RG = _apply, RH = _apply, RI = _apply, RJ = _apply, Check = Args extends readonly unknown[] ? A['constraints'] : A['namedConstraints']> = Result<[RA, RB, RC, RD, RE, RF, RG, RH, RI, RJ]>; type Result = [ T[I] ] extends [never] ? R : I extends T['length'] ? R : Result, T[I]>; type _<$T extends _Type, _, $U> = [$U] extends $T['constraints'] ? any : _Type<[$U]>; export {};