by shortercode · 7y ago · 0 comments
{
let row;
if (row = await db.findOne()) {
//
}
else {
//
}
}Also having "phantom" scope blocks get very nasty to read once you have more involved logic, as the block itself has no implied meaning and the programmer has to walk a few lines into it to get what's going on.
const user = await db.findOne()
if (user) ... else ...
Typescript can even narrow the type to null vs. User in each branch block.