import { Fn, PartialApply, unset, _, Call } from "../core/Core"; export declare namespace Functions { type ParametersImpl = fn extends (...args: infer args) => any ? args : never; export interface ParametersFn extends Fn { return: ParametersImpl; } /** * Returns the parameters of a function. * * @param fn - The function to extract the parameters from. * @returns The parameters of the function. * * @example * ```ts * type T0 = Call void>; // [a: number,b: string] * ``` */ export type Parameters any) | _ | unset = unset> = PartialApply; export interface ParameterFn extends Fn { return: ParametersImpl[this["arg1"]]; } /** * Returns the Nth parameter of a function. * * @param fn - The function to extract the parameter from. * @param N - The index of the parameter to return. * @returns The Nth parameter of the function. * * @example * ```ts * type T0 = Call, (a: number, b: string) => void>; // number * type T1 = Call void>; // string * type T2 = Call void>>; // number */ export type Parameter any) | _ | unset = unset> = PartialApply; type ReturnTypeImpl = fn extends (...args: any[]) => infer ret ? ret : never; /** * ReturnTypes the return type of a function. * * @param fn - The function to extract the return type from. * @returns The return type of the function. * * @example * ```ts * type T0 = Call number>; // number * type T1 = Call number>>; // number * ``` */ export type ReturnType any) | _ | unset = unset> = PartialApply; export interface ReturnTypeFn extends Fn { return: ReturnTypeImpl; } /** * Transforms the return type of a function type. * * @param fn - Type-level function to call on the return type. * @param fnValue - The function type to update. * @returns a function type with an updated return type. * * @example * ```ts * type T0 = Call< * Functions.MapReturnType, * (a: number, b: string) => 1 | 2 * >; * // => (a: number, b: string) => "1" | "2" * ``` */ export type MapReturnType any) | _ | unset = unset> = PartialApply; export interface MapReturnTypeFn extends Fn { return: this["args"] extends [infer fn extends Fn, infer fnValue] ? fnValue extends (...args: infer args) => infer returnType ? (...args: args) => Call : never : never; } /** * Transforms the paramaters of a function type. * * @param fn - Type-level function to call on parameters. * @param fnValue - The function type to update. * @returns a function type with updated parameters. * * @example * ```ts * type T0 = Call< F.MapParameters>, (a: "1" | "2", b: "3" | "4") => void >; * // => (a: 1 | 2, b: 3 | 4) => void * ``` */ export type MapParameters any) | _ | unset = unset> = PartialApply; export interface MapParametersFn extends Fn { return: this["args"] extends [infer fn extends Fn, infer fnValue] ? fnValue extends (...args: infer args) => infer returnType ? (...args: Extract, readonly any[]>) => returnType : never : never; } export {}; }