我正在使用“async”函数,有时我忘记为内部调用添加“await”:
async function doThreeSteps () => {
await firstPromiseReturningFunc();
nonAsyncFunction();
secondPromiseReturningFunc(); //Error here! Need to wait until this call resolves
someOtherStepWhichReliesOnSuccessfullEndingOfPreviousFunction();
}
Run Code Online (Sandbox Code Playgroud)
TypeScript 应该可以警告此类错误,因为 TS 知道每个函数返回什么类型,是承诺还是值。我想让 TS 就此类情况向我发出警告。是否可以?