This proposal defines new syntax to throw exceptions from within an expression context.
(c) tc39
🐊Putout plugin adds ability convert throw statement to expression.
npm i @putout/plugin-convert-throw -D
{
"rules": {
"convert-throw": "on"
},
"plugins": [
"convert-throw"
]
}
const fn = () => {
throw Error('hello');
};
const fn = () => throwError('hello');
MIT