I am mocking the User and need to implement static method findOne which is static so I do not need to extensiate User in my calling class:
export class User implements IUser {
constructor(public name: string, public password: string) {
this.name = 'n';
this.password = 'p';
}
static findOne(login: any, next:Function) {
if(this.name === login.name) //this points to function not to user
//code
return this; //this points to function not to user
}
}
But I can't access this from static function findOne is there a ways of doning it in typescript?
thisfrom a static function. Static functions are called from the class scope, whereas member functions are called from object scope.