-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Closed
Copy link
Labels
Has PRoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
Bug Report
Current Behavior
@babel/plugin-proposal-null-coalescing-operator creates unnecesary variable declaration when variable used in conditional expression is within function scope
function handleChange(inputValue) {
const value = inputValue ?? this.value;
}Expected behavior/code
I expect output to not have additional var _inputValue; declaration because it's unnecessary.
function handleChange(inputValue) {
// since we don't accessing nested property in inputValue the output should be:
var value = inputValue !== null && inputValue !== void 0 ? inputValue : this.value;
}Babel Configuration (.babelrc, package.json, cli command)
{
presets: [
['@babel/preset-env', {
useBuiltIns: true,
loose: true,
modules: false,
corejs: 3,
}],
],
plugins: [
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator'
],
}Environment
- Babel version(s): 7.7.2
- Node/npm version: 13.1.0
- OS: Windows 10
- Monorepo: no
- How you are using Babel: babel-loader
Possible Solution
Additional context/Screenshots
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Has PRoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue