有没有一种方法可以将联合类型转换为交叉类型:
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
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)交叉类型
上面打错字了!