UNPKG

621 BTypeScriptView Raw
1import { Function } from './Function';
2import { Parameters } from './Parameters';
3import { Length as LLength } from '../List/Length';
4/**
5 * Extract arguments' length from a [[Function]]
6 * @param F to extract from
7 * @returns [[String]] or `number`
8 * @example
9 * ```ts
10 * import {F} from 'ts-toolbelt'
11 *
12 * const fn = (a1: any, a2: any) => {}
13 *
14 * type test0 = F.LengthOf<typeof fn> // 2
15 *
16 * type test1 = F.LengthOf<(a1?: any) => any> // 0 | 1
17 *
18 * type test2 = F.LengthOf<(...a: any[]) => any> // number
19 * ```
20 */
21export declare type Length<Fn extends Function> = LLength<Parameters<Fn>>;