有没有一种方法可以将联合类型转换为交叉类型:
type FunctionUnion = () => void | (p: string) => void
type FunctionIntersection = () => void & (p: string) => void
我想申请一个转型FunctionUnion
来获得FunctionIntersection
将联合类型转换为相交类型
有没有一种方法可以将联合类型转换为交叉类型:
type FunctionUnion = () => void | (p: string) => void
type FunctionIntersection = () => void & (p: string) => void
我想申请一个转型FunctionUnion
来获得FunctionIntersection
第4173篇《将联合类型转换为相交类型》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点
type FunctionIntersection<T extends (arg?: any) => void> = (T extends (arg?: any) => void ? (arg: T) => void : never) extends ((arg: infer P) => void) ? P : never
type T = FunctionIntersection<FunctionUnion>
T为(() => void) & ((p: string) => void)联合类型
相似问题
问题类别
type FunctionIntersection<T extends (arg?: any) => void> = (T extends (arg?: any) => void ? (arg: T) => void : never) extends ((arg: infer P) => void) ? P : never
type T = FunctionIntersection<FunctionUnion>
T为(() => void) & ((p: string) => void)交叉类型
上面打错字了!