How check if a function is async in TypeScript

2 Answers

0 votes
async function func() {
 
}
 
const isAsync = func.constructor.name === "AsyncFunction";
 
console.log(isAsync);
  
   
   
   
    
/*
run:
    
true
    
*/

 



answered May 26, 2022 by avibootz
0 votes
const func = async (a : number, b : number) => {
  
};
  
const isAsync = func.constructor.name === "AsyncFunction";
  
console.log(isAsync);
   
    
    
    
     
/*
run:
     
true
     
*/

 



answered May 26, 2022 by avibootz

Related questions

2 answers 144 views
2 answers 244 views
1 answer 125 views
1 answer 155 views
1 answer 210 views
1 answer 222 views
1 answer 136 views
...