Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

void before promise syntax

What is the actual impact of putting void before promise?

async function doAsyncStuff(){
...
}

function nonAsyncFunction(){
  void doAsyncStuff();
}

I couldn't find any official documentation for this, but it must be doing something as it resolves no-floating-promises TSLint error.

like image 278
JeB Avatar asked Jan 01 '23 02:01

JeB


1 Answers

void is an operator that accepts a value on the Right-Hand Side and evaluates as undefined.

It resolves no-floating-promises because it does something (or rather, explicitly nothing) with the promise.

like image 97
Quentin Avatar answered Jan 14 '23 14:01

Quentin