Example code:
class User {
name: String;
constructor(name: String) {
this.name = name;
}
}
User.get = (name):User => {
return new User(name);
}
Use:
// Should return User bob
var user = User.get("bob")
// Should also return User bob
var user = new User("bob")
Error:
Property 'get' does not exist on type 'typeof User'.ts(2339)
I want to know how to define this property so that I don't get this error. Also, yes I know I can just define the get function inside the class User, but for other reasons, I want to be able to call the get function on the class itself.