'Why do I get a type error when destructuring parameters?
When I try to destructure the credentials parameter in the authorize function I get these two type errors:
Property 'email' does not exist on type 'Record<"email" | "password", string> | undefined' Property 'password' does not exist on type 'Record<"email" | "password", string> | undefined'
...
providers: [
CredentialsProvider({
name: "Credentials",
credentials: {
email: { label: "Email", type: "email", placeholder: "[email protected]" },
password: { label: "Password", type: "password" }
},
async authorize({ email, password }) { ... }
]
...
Why is that? Isn't credentials an object containing these two attributes? I even tried to create an interface for it and so on but then the function threw a type error.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
