Greater Than
提出詳細
type _SubUnwrap<T> = T extends { __rec: never } ? never : T extends { __rec: { __rec: infer U } } ? { __rec: _SubUnwrap<U> } : T extends { __rec: infer U } ? U : T; type Unwrap<T, H extends "__hack" = "__hack"> = T extends { __rec: unknown } ? { [H0 in H]: Unwrap<_SubUnwrap<T>> }[H] : T; type WrapedTnum<T, N extends number, A extends T[] = []> = A["length"] extends N ? A : { __rec: WrapedTnum<T, N, [T, ...A]> }; type ArgsFunc<N extends number, A = Unwrap<WrapedTnum<false, N>>> = A extends unknown[] ? (...args: A) => void : never type GreaterThan<T extends number, U extends number> = ArgsFunc<T> extends ArgsFunc<U> ? false : true
提出日時 | 2023-08-13 09:39:55 |
---|---|
問題 | Greater Than |
ユーザー | ookkoouu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<GreaterThan<1, 0>, true>>, Expect<Equal<GreaterThan<5, 4>, true>>, Expect<Equal<GreaterThan<4, 5>, false>>, Expect<Equal<GreaterThan<0, 0>, false>>, Expect<Equal<GreaterThan<20, 20>, false>>, Expect<Equal<GreaterThan<10, 100>, false>>, Expect<Equal<GreaterThan<111, 11>, true>>, ]