Created
February 8, 2023 08:39
-
-
Save Noviny/4152c0d79242218fe4eb49451317d229 to your computer and use it in GitHub Desktop.
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
export type Combine<T> = { | |
[K in keyof T]: T[K]; | |
} & {}; | |
type One = { | |
one: number; | |
}; | |
type Two = { | |
two: number; | |
}; | |
type Three = { | |
three: number; | |
}; | |
/* | |
Shows definition as | |
type Added = One & Two & Three | |
*/ | |
type Added = One & Two & Three; | |
/* Gives good types of: | |
type Combined = { | |
one: number; | |
two: number; | |
three: number; | |
} | |
*/ | |
type Combined1 = Combine<Added>; | |
type Combined2 = Combine<One & Two & Three>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment