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
// Typescript accessor fields are not part of the serilization process | |
// A Proxy object serves the purpose ina very elegant way | |
// Other alternative would be to use `Object.defineProperty` | |
class Q { | |
constructor(init: number) { | |
var proxy = new Proxy(this, { | |
get: (target, prop, receiver) => { | |
if (prop === "msg") { | |
return `Number is ${this.value}`; |