K
K
krs2019-08-06 21:53:44
typescript
krs, 2019-08-06 21:53:44

Typescript, mandatory await promise void function warning, or at least a warning?

async function test() : Promise<void>{
  //some async actions
}
async function test2() : Promise<number>
{
  await test();
  return 123;
}
test2().then(() => {
  alert('ok');
});

How to make typescript be sure to throw an error or warning if an async function was not executed while another async function was executing. For example, the following code will generate an error or a warning
async function test() : Promise<void>{
  //some async actions
}
async function test2() : Promise<number>
{
  test();
  return 123;
}
test2().then(() => {
  alert('ok');
});

Here the test function is called but not executed...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Inviz Custos, 2019-08-07
@krs

https://www.meziantou.net/detect-missing-await-in-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question