void before promise syntax

寵の児 提交于 2021-01-28 04:06:38

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/55558875/void-before-promise-syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!