我有以下内容:
interface IUser {
email: string
password: string
}
class User {
email: string
password: string
constructor(email: string, password: string) {
this.email = email
this.password = password
}
isEmailValid(): boolean {
return validatorJs.isEmail(this.email)
}
isPasswordValid(): boolean {
return validatorJs.isStrongPassword(this.password, opts)
}
}
function createUser(user: IUser) {
// applying isPasswordValid and isEmailValid
//insert ...
}
function getUser(): IUser {
return new User('foo@bar.com', 'foobar')
}
Run Code Online (Sandbox Code Playgroud)
我必须在接口名称前加上字母“I”,这是正确的还是我应该采取不同的做法?
typescript ×1