I am fairly used to seeing promises handled in the then
/catch
style in TypeScript, such as:
.findById(id)
.then((result: something | undefined) => result ?? dosomething(result))
.catch((error: any) => console.log(error))
However I also see the pattern where void is used to prevent the floating promise and indeed it is sometimes recommended by my language server as a fix.
void somePromise().dosomething();
Now, I'm not particularly versed in TypeScript or promises at all but I'm struggling to see how it would ever be preferable to skip using catch and simply use void. Brief googling didn't give me any clear distinction on when to do what.
There is this other answer explaining what void does, but not why I would want to use it. And there are various questions relating to solving floating promises but none that I could find detailing why I would take the void approach over catch.