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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…