type Optional<T,K extends keyof T> = Omit<T,K> & Partial<Pick<T,K>>
interface WindowState {
isMaximized: boolean;
isFullScreen: boolean;
data: string;
count: number;
}
type CreateWindowState = Optional<WindowState, 'isMaximized' | 'isFullScreen'>;
//CreateWindowState相当于如下的OptionalWindowState
interface OptionalWindowState {
isMaximized?: boolean;
isFullScreen?: boolean;
data: string;
count: number;
}
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
type A = UnionToIntersection<{ a: (v: number) => void } | { b: (v: string) => void }>;
type B = UnionToIntersection<{a:string} | {b:number}>