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

55 - Union to Intersection #18930

Open
CaoXueLiang opened this issue Nov 10, 2022 · 0 comments
Open

55 - Union to Intersection #18930

CaoXueLiang opened this issue Nov 10, 2022 · 0 comments
Labels
55 answer Share answers/solutions to a question en in English

Comments

@CaoXueLiang
Copy link

CaoXueLiang commented Nov 10, 2022

// 1. 将Union类型变成函数的联合函数类型
type ToUnionFunction<T> = T extends unknown ? (arg: T) => void : never;

// 2. 联合函数的类型,怎么就变成了交叉参数的一个函数?
//    ts对应PR:https://github.com/Microsoft/TypeScript/pull/21496
type UnionToIntersection<U> = ToUnionFunction<U> extends (arg: infer Args) => void ? Args : never;
@CaoXueLiang CaoXueLiang added answer Share answers/solutions to a question en in English labels Nov 10, 2022
@github-actions github-actions bot added the 55 label Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
55 answer Share answers/solutions to a question en in English
Projects
None yet
Development

No branches or pull requests

1 participant