ascoders/weekly

精读《type challenges - easy》

ascoders opened this issue · 9 comments

读一读类型挑战 - easy 难度的题目,总结一下用到了哪些特性与思维方式。


精读《type challenges - easy》

image

Last 第二个参数设置为默认值似乎也是合法的?

对,因为默认值写的是 any[] 而不是 [],当然此时 Others 类型就定死了是 any[] 而不是 ['1', '2'] 了,只解决当前问题,但 Others 类型不清晰,还是有潜在问题的。

元组长度这边,应该还要考虑 readonly。

这个Equal 好像不行,写什么上去都是ture
image


Pick
Pick的答案二应该是
type MyPick<T, K extends keyof T> = { [P in K]: T[P] }