Add trycatch to your magic comment
npm install babel-plugin-catch or yarn add babel-plugin-catch
const test = (num/* catch */) => {
}
class Test{
test(num, num2/* catch */){
}
test = (num, num2/* catch */) => {
}
}
.babelrc
{
"plugins": [
["babel-plugin-catch", {
comment?: 'catch',
catchCode?: (e) => {
},
finallyCode?: () =>{
}
}]
]
}
$ babel --plugins babel-plugin-catch script.js
require("babel-core").transform("code", {
plugins: ["babel-plugin-catch"]
});