-
-
Save CheatEx/4f771744bd393bd305660846c10df016 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
class Message { | |
greeting: string; | |
body: string; | |
data: number; | |
constructor(greeting: string, body: string, data: number) { | |
this.greeting = greeting; | |
this.body = body; | |
this.data = data; | |
} | |
//already sucks - triple repetition | |
} | |
type Greeting = Message & { name: string;} | |
let m: Message = new Message("hey", "im a message", 42); | |
function doActualStuff(g: Greeting): void { | |
console.log(g.name); | |
} | |
let g = m; | |
g.name = "Vasya"; | |
g.anotherFieldNeededElsewhere = true; | |
doActualStuff(g); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment