@babel/plugin-proposal-optional-catch-binding

Examples

  1. try {
  2. throw 0;
  3. } catch {
  4. doSomethingWhichDoesNotCareAboutTheValueThrown();
  5. }
  1. try {
  2. throw 0;
  3. } catch {
  4. doSomethingWhichDoesNotCareAboutTheValueThrown();
  5. } finally {
  6. doSomeCleanup();
  7. }

Installation

  1. npm install --save-dev @babel/plugin-proposal-optional-catch-binding

Usage

.babelrc

  1. {
  2. "plugins": ["@babel/plugin-proposal-optional-catch-binding"]
  3. }

Via CLI

  1. babel --plugins @babel/plugin-proposal-optional-catch-binding script.js

Via Node API

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

References