type Reverse<T extends any[], A extends any[] = []> = T extends [...infer Rest, infer R] ? Reverse<Rest, [...A, R]> : A
Solution by wendao-liu #35180
type Reverse<T> = T extends [...infer Rest,infer Last] ? [Last, ...Reverse<Rest>] : T
Solution by devshinthant #34951
type Reverse<T extends string[]> = T extends [infer First, ...infer Rest extends string[]] ? [...Reverse<Rest>, First&string] : []
Solution by maximallain #34772
// 你的答案
type Reverse<T extends any[], U extends any[] = []> = T extends [infer F, ...infer S] ? Reverse<S, [F, ...U]> : U
Solution by Jayce-liang #34764
// your answers
type Reverse<T> = T extends [...infer F, infer L] ? [L,...Reverse<F>] : T
Solution by gobielJonathan #34529
type Tail<T extends unknown[]> = T extends [unknown, ... infer R] ? R : never;
type Reverse<
Xs extends unknown[],
Acc extends unknown[] = []
> = Xs extends [] ? Acc : Reverse<Tail<Xs>, [Xs[0], ...Acc]>
Solution by souzaramon #34267
type Reverse<T extends any[], U extends any[] = []> = T extends [...infer rest, infer R] ? Reverse<rest, [...U, R]> : U
Solution by ouzexi #34057
type Reverse<T extends any[], A extends any[] = []> = T extends [${infer S}
, ...infer AA] ? Reverse<AA, [S, ...A]>:A
Solution by rookiewxy #33854
type Reverse<T extends any[]> = T extends [infer F, ...infer L] ? [...Reverse<L>, F] : T;
Solution by ZhipengYang0605 #33225
// your answers
type Reverse<T extends any[]> = T extends [...infer L, infer R]? [R, ...Reverse<L>] : T
Solution by pea-sys #32963
// your answers
type Reverse<T extends readonly any[]> = T extends [...infer Rest,infer Last] ? [Last,...Reverse<Rest>]:T;
Solution by sciencefunq #32922
type Reverse<T extends unknown[], Acc extends unknown[] = []> = T extends [infer F, ...infer Rest]
? Reverse<Rest, [F, ...Acc]>
: Acc
Solution by ZhulinskiiDanil #32728
type Reverse<T extends any[]> = T extends [infer F, ...infer Rest]
? [...Reverse<Rest>, F]
: [];
Solution by kai-phan #32516
type Reverse<T, U extends unknown[] = []> = T extends [...infer F, infer Last]
? F["length"] extends 0
? [...U, Last]
: Reverse<F, [...U, Last]> //
: [];
Solution by gasmg #32208
type Reverse<T extends unknown[]> = T extends [... infer R, infer L] ? [L, ...Reverse<R>] : T;
Solution by ricky-fn #31918
type Reverse<
T extends any[],
U extends any[] = []
> = U["length"] extends T["length"] ? U : Reverse<T, [T[U["length"]], ...U]>;
Solution by vipulpathak113 #31785
// 递归
type Reverse<T extends unknown[]> = T extends [infer First, ...infer Rest] ? [...Reverse<Rest>, First] : T
Solution by Yand-hi #30019
Solution:
type Reverse<T extends any[]> = T extends [infer F, ...infer R] ? [...Reverse<R>, F] : T;
Solution by DmitriiBr #29555
type Reverse<T extends any[]> = T extends [infer A, ...infer B] ? [...Reverse<B>, A]: [];
type R = Reverse<[1, 2, 3, 4]>;
Solution by sundial-dreams #29492
type Reverse<T extends any[], Result extends any[] = []> = T extends [...infer A, infer B] ? Reverse<A, [...Result, B]> : Result
Solution by dmytro-shumak #29225
type Reverse<T extends unknown[]> = T extends [infer F, ...infer R] ? [...Reverse<R>, F] : T;
Solution by DoubleWoodLin #28700
// your answers
type Reverse<T extends any[]> = T extends [infer F, ...infer Rest] ? [...Reverse<Rest>, F] : T;
Solution by daiki-skm #28127
type Reverse<T extends any[], Acc extends any[] = []> = T extends [infer A, ...infer Rest] ? Reverse<Rest, [A, ...Acc]> : Acc
Solution by devSoyoung #27725
type Reverse<T extends any[], U extends any[] = []> = T extends [...infer O, infer L] ? Reverse<O, Push<U, L>> : U;
Solution by 8471919 #27696
type Reverse<T extends any[], P extends any[] = []> = T extends [infer L, ...infer R] ? Reverse<R, [L, ...P]>: P
Solution by isntkyu #27687
type Reverse<T extends unknown[]> = T extends [infer First, ...infer Tail] ? [...Reverse<Tail>, First] : []
Solution by jjswifty #27635
type Reverse<T, S extends string[] = []> = T extends [...infer Pre, infer Next] ? Reverse<Pre, [...S, Next & string]> : S
Solution by jiechliu #27450
type Reverse<T extends any[], R extends any[] = []> = T extends [...infer F, infer L] ? Reverse<F, [...R, L]> : R
Solution by ZhipengYang0605 #27255
type Reverse<T extends any[]> = T extends [...infer F, infer R] ? [R, ...Reverse<F>] : T
Solution by RainbowIsPerfect #27051
type Reverse<T extends unknown[]> = T extends [...infer Rest, infer Last]
? [Last, ...Reverse<Rest>]
: T
Solution by HubooDeclan #27030