Skip to main content

@babel/plugin-proposal-discard-binding

转换放弃将 const [void, x] = arr 绑定到 const [, x] = arr

¥Transforms discard binding const [void, x] = arr to const [, x] = arr

示例

¥Example

JavaScript
const [void, x] = arr;
using void = getResource();

将转变为

¥will be transformed to

JavaScript
const [, x] = arr;
using _ = getResource();

该插件尊重这些编译器假设:

¥The plugin respects these compiler assumptions:

安装

¥Installation

npm install --save-dev @babel/plugin-proposal-discard-binding

用法

¥Usage

¥With a configuration file (Recommended)

babel.config.json
{
"plugins": ["@babel/plugin-proposal-discard-binding"]
}

通过 CLI

¥Via CLI

Shell
babel --plugins @babel/plugin-proposal-discard-binding script.js

通过 Node API

¥Via Node API

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

选项

¥Options

syntaxType

必需的。

¥Required.

"void"

选择表示丢弃绑定的语法类型。目前仅支持 "void"

¥Choose the syntax type to represent the discard binding. Currently the only supported value is "void".

参考

¥References