Skip to main content

@babel/plugin-syntax-optional-chaining-assign

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-optional-chaining-assign to both parse and transform this syntax.

This plugin enables parsing for obj?.prop = val; assignments.

Installation

npm install --save-dev @babel/plugin-syntax-optional-chaining-assign

Usage

babel.config.json
{
"plugins": ["@babel/plugin-syntax-optional-chaining-assign"]
}

Via CLI

Shell
babel --plugins @babel/plugin-syntax-optional-chaining-assign script.js

Via Node API

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