how to rewrite below javascript in typescript class. The greet2 function in prototype is an immediately invoke function.
function Greeter(greeting) {
this.greeting = greeting;
}
Greeter.prototype.greet = function() {
return "Hello, " + this.greeting;
}
//an immediately invoke function
Greeter.prototype.greet2 = function{
let blabla = 'hello, ';
return function greet2(foo) {
return blabla + foo;
}
}();
let greeter = new Greeter({message: "world"});
let button = document.createElement('button');
button.textContent = "Say Hello";
button.onclick = function() {
alert(greeter.greet2('tom'));
};
document.body.appendChild(button);