@babel/plugin-proposal-throw-expressions

Example

  1. function test(param = throw new Error('required!')) {
  2. const test = param === true || throw new Error('Falsy!');
  3. }

Installation

  1. npm install --save-dev @babel/plugin-proposal-throw-expressions

Usage

  1. {
  2. "plugins": ["@babel/plugin-proposal-throw-expressions"]
  3. }

Via CLI

  1. babel --plugins @babel/plugin-proposal-throw-expressions script.js

Via Node API

  1. require("@babel/core").transform("code", {
  2. plugins: ["@babel/plugin-proposal-throw-expressions"]
  3. });

References