-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
精读《Typescript 4.0》 #259
Comments
不知道啥时能支持对类型名的转换,比如类型名追加字符串。 |
@waitingsong 能举一个 case 吗 |
@ascoders 笔记中 取动态交集类型可以用 Conditional types 配合 Type inference in conditional types 的黑魔法。 type IntersectionFromUnion<TUnion> = (TUnion extends any
? (arg: TUnion) => void
: never) extends (arg: infer TArg) => void
? TArg
: never
const useDesigner = <T extends Array<(state?: any) => any>>(
...selectors: T
): IntersectionFromUnion<ReturnType<T[number]>> =>
useSelector(state =>
selectors.reduce((selected, selector) => {
return {
...selected,
...selector(state)
}
}, {} as any)
) |
|
有望在 4.1 版本实现 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Typescript 4 Beta 版来啦!,虽然是一个大版本,但从 3.9 升级到 4 不会遇到太大问题,让我们一起了解一下内容吧。
精读《Typescript 4.0》
The text was updated successfully, but these errors were encountered: