interface FindUserEmailProps {
readonly email: string
}
interface FindUserIdProps {
readonly id: string
}
type FindUserProps = FindUserEmailProps | FindUserIdProps
export const findUserByEmail = async ({ email }: FindUserProps): Promise<IUser> => {
const user = await User.findOne({ email })
if (!user) {
throw new Error('User not found')
}
return user
}
I am experiencing an issue with the TS2339 error stating that 'Property 'email' does not exist on type 'FindUserProps'. Can anyone help explain why this is happening?