@babel/plugin-proposal-throw-expressions
Example
function test(param = throw new Error('required!')) {
const test = param === true || throw new Error('Falsy!');
}
Installation
npm install --save-dev @babel/plugin-proposal-throw-expressions
Usage
Via .babelrc (Recommended)
.babelrc
{
"plugins": ["@babel/plugin-proposal-throw-expressions"]
}
Via CLI
babel --plugins @babel/plugin-proposal-throw-expressions script.js
Via Node API
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-proposal-throw-expressions"]
});