Answer the question
In order to leave comments, you need to log in
How to type new functions?
Link to the sandbox
interface IPerson {
name: string;
sayHello(): string;
}
const Welcome = function (this: IPerson, name: string) {
this.name = name;
}
Welcome.prototype.sayHello = function () {
return "Hello, " + this.name + "!";
};
interface PersonConstructor {
new(name: string): IPerson;
}
var welcome = new Welcome("John");
console.log(welcome.sayHello());
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question