TsLint 抱怨调用顶级异步方法

TsLint complains about calling top level async method

我已将 TsLint 配置为针对未处理的承诺发出警告:

{
    "rules": {
        "no-floating-promises": [
          true,
          "Promise",
          "Q.Promise" 
        ],
    }
}

代码遵循 standard template for build tasks for vsts:

async function run() {
  try {
      ...
  } catch (err) {
      tl.setResult(tl.TaskResult.Failed, err.message);
  }
}

run(); // tslint complains here...

TsLint 现在抱怨 promise 未处理,但我无法在 run 之前添加等待...我不想将 运行 与 .then 混合使用引入另一种异步范式...

ERROR: C:/Users/JesseHouwing/Source/Repos/....ts[16, 5]: Promises must be handled appropriately

这些任务在 Node 中执行,不等待 run 方法,它工作正常...我可以安全地抑制它吗?有更好的方法吗?

看来我可以安全地抑制该值,方法是:

async function run() {
  try {
      ...
  } catch (err) {
      tl.setResult(tl.TaskResult.Failed, err.message);
  }
}

void run(); // tslint no longer complains here and it's explicit :)

在顶级 run 方法前面插入 void 似乎可以解决这个问题。