Skip to main content

@babel/plugin-syntax-throw-expressions

note

Syntax only

It's unlikely you want to use this plugin directly as it only enables Babel to parse this syntax. Instead, use plugin-proposal-throw-expressions to both parse and transform this syntax.

JavaScript
function test(param = throw new Error('required!')) {
const test = param === true || throw new Error('Falsy!');
}

Installation

npm install --save-dev @babel/plugin-syntax-throw-expressions

Usage

babel.config.json
{
"plugins": ["@babel/plugin-syntax-throw-expressions"]
}

Via CLI

Shell
babel --plugins @babel/plugin-syntax-throw-expressions script.js

Via Node API

JavaScript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-syntax-throw-expressions"]
});