我的模型界面
export interface IUser extends Document {
name: string;
email: string;
photo: string;
password: string;
passwordConfirm: string | undefined;
correctPassword: (candidatePassword: string, userPassword: string) => boolean;
changedPasswordAfter: (timestamp: string) => Date;
}
我的模型 -
export const User = model<IUser>('user', userSchema);
我的实例方法-
userSchema.methods.changedPasswordAfter = function (timestamp: string): Date {
if (this.passwordChangedAt) {
//
}
return false;
};
打字稿显示的错误 - 类型 Document<any>
上不存在属性“passwordChangedAt”
这是为什么?我该如何解决这个问题?