Here's my schema validator code for MongoDB:
UserSchema.path('email').validate(async function (email: string) {
const count = await User.count({ email, _id: { $ne: this._id } })
return !count
}, 'Email already exists')
However, I'm encountering the following error:
'this' implicitly has type 'any' because it does not have a type annotation.ts(2683)
User.ts(171, 35): An outer value of 'this' is shadowed by this container.
This issue arises in my User.ts
file. The functionality works as intended, but this Typescript error is causing problems during CI. Is there a solution to resolve this hiccup?