Typescript Interface Flattening

Viewed 45

I have the following Typescript interface:

export interface Teammate {
  id: number;
  name: string;
  user: {
    email: string;
  };
}

That's how it comes from a GraphQL server, and I can't seem to "transform" it using Apollo Client. My question is, can I somehow create an email attribute of the above interface that would automatically "copy" the value from the nested attribute?

...as follows:

export interface Teammate {
  id: number;
  name: string;
  email: <= a function/Typescript method to copy user.email somehow over here?
  user: {
    email: string;
  };
}

Thanks, Sammy

0 Answers
Related