Skip to content

Instantly share code, notes, and snippets.

@CheatEx
Last active January 31, 2019 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CheatEx/75e9192ee7bc8fbd289b52c9caa960d1 to your computer and use it in GitHub Desktop.
Save CheatEx/75e9192ee7bc8fbd289b52c9caa960d1 to your computer and use it in GitHub Desktop.
class Message {
greeting: string;
body: string;
data: number;
}
function doActualStuff(g: Message & { name: string; }): void {
console.log(g.name);
}
let m: Message = {greeting: "hey", body: "im a message", data: 42};
let g = {
...m,
name: "Vasya",
anotherFieldNeededElsewhere: true,
};
doActualStuff(g);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment