Typescript类型体操 - Shift
题目
中文
实现类型版本的 Array.shift
English
Implement the type version of Array.shift
For example
type Result = Shift<[3, 2, 1]>; // [2, 1]
答案
type Shift<T extends any[]> = T extends [any, ...infer R] ? R : never;
实现类型版本的 Array.shift
Implement the type version of Array.shift
For example
type Result = Shift<[3, 2, 1]>; // [2, 1]
type Shift<T extends any[]> = T extends [any, ...infer R] ? R : never;