logo

Todash 2.4.0

是一个 类型推导 工具库,旨在帮助你快速方便的编写具备类型推导的 TypeScript 代码。


“Tuple” 方法


_.TupleByUnionUnshift<tuple, type>

TupleByUnionUnshiftUnion 情况专用处理函数 将一个类型添加元组的开头,并返回「暴力枚举后」的「元组联合类型」


参数


tuple (Tuple): 需要处理的元组
type (unknown): 需要被添加到元组中的类型


返回


tuple (Tuple): 首部被添加一项后的元组


例子


type TupleAfterUnionUnshift = _.TupleByUnionUnshift<['angular'], 'react' | 'vue'>;
// => ['react', 'angular'] | ['vue', 'angular']

type TupleAfterUnionUnshift = _.TupleByUnionUnshift<['angular'] | ['solid'], 'react' | 'vue'>;
// => ['react', 'angular'] | ['vue', 'angular'] | ['react', 'solid'] | ['vue', 'solid']

// diff with TupleByUnshift
type TupleAfterUnshift = _.TupleByUnshift<['angular'], 'react' | 'vue'>;
// => ['react' | 'vue', 'angular']