Created
December 28, 2021 19:49
-
-
Save garenyondem/62a0c89c66a8fd6d80ff6cea504a1eab to your computer and use it in GitHub Desktop.
Typescript Flatten two types
This file contains hidden or 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 Flatten<T> = T extends object ? { | |
[P in keyof T]: Flatten<T[P]> | |
} : T; | |
type A = { foo: boolean } & { bar: string }; | |
type B = Flatten<A>; // { foo: boolean; bar: string; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment