I need to find users whose tokens have not expired yet.
try {
const user = await User.findOne({
resetToken: passwordToken,
resetTokenExpiration: { $gt: Date.now() },
_id: userId,
});
if (!user) {
throw new NotFoundError();
}
in plain javascript it had no issue. in typescript i am getting this error:
Type 'number' is not assignable to type 'Date | undefined'.
typescript evaluates $gt: Date.now() as type annotation. I am converting my node.js project to typescript and this is the only thing that I could not figure out.