Type Promise not asignable to type Awaitable
What am I doing wrong here and how can I fix it?
6 Replies
Can you give some more context
Sure, this is not really an error, the function works just fine but vscode is screaming at me. The db is in mysql, this query just looks for the user using the email and stores it in the next-auth session which uses jwt strategy and a credentials provider. logging the user returns the user correctly and if it doesn't find it, it ends up beign null but for some reason whenever I try to write a return user, it gives me that vscode error. As far as I know prisma.findUnique returns a js object after the promise resolves or null if it doesn't find it. It stops screaming at me if I return a hardcoded object. My guess is that maybe authorize expects an Awaitable object instead of just a promise? I wouldn't know how to debug it either since ts is pretty new for me and I'm a bit lost. Also the project is built with t3 app and it's like the first thing that I'm doing on it so there's like nothing else in the app.
Can you scroll further down on the error message?
@Alejo
Hm, at a glance it would seem that name in the prisma schema is nullable, whereas the function expects the return type of the function to be
but your function is returning
You'd need to either provide a default value to
user.name
before returning it and making sure Typescript understands that that value is not null, you can do that by doing something like
Alternatively the other option is modifying your prisma schema to make name
a required field for usersI get it now, thanks!