Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

精读《type challenges - easy》 #422

Closed
ascoders opened this issue Jun 4, 2022 · 5 comments
Closed

精读《type challenges - easy》 #422

ascoders opened this issue Jun 4, 2022 · 5 comments

Comments

@ascoders
Copy link
Owner

ascoders commented Jun 4, 2022

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


精读《type challenges - easy》

@ascoders ascoders closed this as completed Jun 6, 2022
@huyansheng3
Copy link

image

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

@ascoders
Copy link
Owner Author

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

@likoshow
Copy link

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

@biluox
Copy link

biluox commented Jul 20, 2022

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


@MyKyle19
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants