Created
May 17, 2021 17:43
-
-
Save millsp/cfefce1977bdd347b32cb51e5f59390d to your computer and use it in GitHub Desktop.
Unionize Deep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MarkUndefinable<A, B> = { | |
[K in keyof A]: A[K] extends O.Object | |
? MarkUndefinable<A[K], A.At<B, K>> | |
: K extends keyof B ? A[K] | undefined : A[K] | |
} | |
type UnionizeDeep<A extends object, B extends object> = | |
O.Merge<MarkUndefinable<A, B>, B, 'deep', M.BuiltIn, undefined> | |
type test = A.Compute<UnionizeDeep<{ | |
name?: string, | |
age?: string, | |
details: { | |
ccn: string, | |
address: { | |
no: string | |
name: string | |
} | |
} | |
}, { | |
name: { | |
first: string | |
last: string | |
}, | |
age?: number, | |
details: { | |
ccv: string | |
address: { | |
no: number | |
name: string | |
} | |
} | |
}>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment