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
}
At email property I got TS2339: Property 'email' does not exist on type 'FindUserProps' Why is that?