Skip to content

Instantly share code, notes, and snippets.

@Noviny
Created February 8, 2023 08:39
Show Gist options
  • Save Noviny/4152c0d79242218fe4eb49451317d229 to your computer and use it in GitHub Desktop.
Save Noviny/4152c0d79242218fe4eb49451317d229 to your computer and use it in GitHub Desktop.
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