Skip to content

Instantly share code, notes, and snippets.

@hmmhmmhm
Last active September 20, 2022 05:19
Show Gist options
  • Save hmmhmmhm/39922d389eb4b00a9c320e0f0af97d85 to your computer and use it in GitHub Desktop.
Save hmmhmmhm/39922d389eb4b00a9c320e0f0af97d85 to your computer and use it in GitHub Desktop.
Remove some depth of typescript interface
interface T1 {
name: string;
email: string;
properties: {
creators: [{
name: string;
}];
color: string;
}
}
type Overwrite<T, U> = { [P in Exclude<keyof T, keyof U>]: T[P] } & U;
type T7 = Omit<T1, "properties"> & { properties: Omit<T1["properties"], "creators"> };
type T8 = Overwrite<T1,{properties: {color: string}}>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment