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

联合类型的特殊点 #8

Open
xiaochengzi6 opened this issue Feb 23, 2023 · 0 comments
Open

联合类型的特殊点 #8

xiaochengzi6 opened this issue Feb 23, 2023 · 0 comments

Comments

@xiaochengzi6
Copy link
Owner

  1. 分布式条件类型
    当联合类型为参数并且在判断条件左边的时候就会触发分布式条件类型 它会将每一个数单独传入做类型运算然后在合并成联合类型返回
type IsUnion<A, B = A> = A extends A ? [B] extends A ? false : true : false

这里的 A extends A 就触发了这样的规则,联合类型 A 将其元素依次传入和 联合类型 A 比较
具体介绍看小册

  1. 数组转换成联合类型
type union = ['aaa', 'bbb'][number]
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

1 participant