We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We probably want to solve #128 before looking at what the typescript version would look like.
The text was updated successfully, but these errors were encountered:
Here is some help:
type ChooseItem<A, B, K> = K extends keyof B ? (K extends keyof A ? MergeTypes<A[K], B[K]> : B[K]) : K extends keyof A ? A[K] : never; type MergeIndividually<A, B> = { [K in keyof A]: ChooseItem<A, B, K> } & { [K in keyof B]: ChooseItem<A, B, K> } type MergeTypes<A, B = A> = A extends object ? (B extends object ? MergeIndividually<A, B> : B) : B; // Examples: type Z = MergeTypes<number, string>; type X = MergeTypes<{ a: {a: number, b: number, z: {x: number, y: number}} }, { a: {a: string, c: number, z: {x: number, y: string, t: string}} }> declare let v:X; let m = v.a.z.y
Playground: http://bit.ly/2PmXu9X
Sorry, something went wrong.
But if you are okay with assuming that primitives are always of the same type, a simple type MergeTypes<A, B> = A & B will be sufficient.
type MergeTypes<A, B> = A & B
No branches or pull requests
We probably want to solve #128 before looking at what the typescript version would look like.
The text was updated successfully, but these errors were encountered: