https://zhuanlan.zhihu.com/p/136254808
// 这里定义一个工具类型,简化代码type ReplaceValByOwnKey<T, S extends any> = { [P in keyof T]: S[P] };// shift actiontype ShiftAction<T extends any[]> = ((...args: T) => any) extends ((arg1: any, ...rest: infer R) => any) ? R : never;// unshift actiontype UnshiftAction<T extends any[], A> = ((args1: A, ...rest: T) => any) extends ((...args: infer R) => any) ? R : never;// pop actiontype PopAction<T extends any[]> = ReplaceValByOwnKey<ShiftAction<T>, T>;// push actiontype PushAction<T extends any[], E> = ReplaceValByOwnKey<UnshiftAction<T, any>, T & { [k: string]: E }>;// test ...type tuple = ['vue', 'react', 'angular'];type resultWithShiftAction = ShiftAction<tuple>; // ["react", "angular"]type resultWithUnshiftAction = UnshiftAction<tuple, 'jquery'>; // ["jquery", "vue", "react", "angular"]type resultWithPopAction = PopAction<tuple>; // ["vue", "react"]type resultWithPushAction = PushAction<tuple, 'jquery'>; // ["vue", "react", "angular", "jquery"]