I am creating an object (a dummy http response object) as illustrated below:
res = {
body : '',
write : (text : string) => {
this.body = this.body + text;
},
end : () => {}
};
But the typescript compiler is giving error:
error TS2108: 'this' cannot be referenced within module bodies.
I know this is possible (to have this inside object) in javascript, how to accomplish this in typescript?