import { Extends } from '../../commonness/Extends'; import { GreaterThan } from '../../number/GreaterThan'; import { Tuple } from '../../primitive/Tuple'; /** * * Type to find the maximum value in a tuple of numbers * * 숫자 튜플에서 최대값을 찾는 타입 * * @param T Tuple of numbers / 숫자 튜플 * * @returns Maximum value in the tuple / 튜플 내 최대값 * * @example * type cases = [ * Expect, 3>>, * Expect, 9>>, * Expect, 1>>, * ] * * @link https://www.utilscript.site/docs/usage-array/max * */ export type Max, R extends number = T[0]> = T extends readonly [ infer First extends number, ...infer Rest extends Tuple ] ? GreaterThan extends true ? Max : Max : Extends extends true ? never : R;