Skip to content

Latest commit

 

History

History
61 lines (46 loc) · 1.08 KB

plugin-proposal-optional-catch-binding.md

File metadata and controls

61 lines (46 loc) · 1.08 KB
Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 8
---
id: babel-plugin-proposal-optional-catch-binding
title: @babel/plugin-proposal-optional-catch-binding
sidebar_label: optional-catch-binding
---

NOTE: This plugin is included in @babel/preset-env, in ES2019

Examples

try {
  throw 0;
} catch {
  doSomethingWhichDoesNotCareAboutTheValueThrown();
}
try {
  throw 0;
} catch {
  doSomethingWhichDoesNotCareAboutTheValueThrown();
} finally {
  doSomeCleanup();
}

Installation

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

Usage

With a configuration file (Recommended)

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

Via CLI

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

Via Node API

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

References