How to return void from function (not return any value) in TypeScript

2 Answers

0 votes
function test(): void { 
    console.log("test()")
} 

test();

   
  
   
   
/*
   
run:

"test()" 
  
*/

 



answered Oct 24, 2021 by avibootz
0 votes
function test(): void { 
    console.log("test()")
} 

let result: void = test(); 

console.log(result); 
   
  
   
   
/*
   
run:
   
"test()" 
undefined 
  
*/

 

 



answered Oct 24, 2021 by avibootz

Related questions

1 answer 163 views
1 answer 168 views
168 views asked Dec 4, 2016 by avibootz
1 answer 184 views
1 answer 147 views
1 answer 151 views
...