If I keep my code like this I get the error mentioned in the title, so how can I tell TypeScript that's safe doing so because we will run the query only if the user is authenticated?
Instead, if I change it to
session?.user.id
session?.user.id
I get the "Overload matches error" ending with
Type 'undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.