[TypeScript@2.5] Omit catch error block if not needed

From TypeScript@2.5, you can omit catch error block.

Before:

try {
  throw new Error('whatever');
} catch(err) {
   console.log(err)  
}

 

Now:

try {
  throw new Error('whatever');
} catch {
   console.log("error happened")  
}

 

It is just a syntax sugar, if you are not trying to do error handling

posted @ 2017-09-06 22:34  Zhentiw  阅读(214)  评论(0)    收藏  举报