💻
How are you using Babel?
@babel/cli
Input code
function v1() {
let v1 = new.target;
}
var v3 = new v1();
Here is the REPL
Configuration file name
babel.config.json
Configuration
{
"sourceType": "unambiguous",
"presets": ["@babel/preset-env"],
"plugins": [
"@babel/plugin-transform-runtime"
]
}
Current and expected behavior
Inside the function, this bug will be triggered when the variable name and function name happen to be the same and the variable is a new target. The transpiled code run by node will report the following error:
var v1 = this instanceof v1 ? this.constructor : void 0;
^
TypeError: Right-hand side of 'instanceof' is not an object
Environment
- babel
- ├── @babel/cli@7.17.0=6
- ├── @babel/generator@7.17.3
- ├── @babel/plugin-transform-runtime@7.17.0
- ├── @babel/preset-env@7.16.11
- Node: [v17.3.0]
- npm version [8.5.2]
- os [ubuntu 20.04]
Possible solution
No response
Additional context
No response
💻
How are you using Babel?
@babel/cli
Input code
Here is the REPL
Configuration file name
babel.config.json
Configuration
{ "sourceType": "unambiguous", "presets": ["@babel/preset-env"], "plugins": [ "@babel/plugin-transform-runtime" ] }Current and expected behavior
Inside the function, this bug will be triggered when the variable name and function name happen to be the same and the variable is a new target. The transpiled code run by node will report the following error:
Environment
Possible solution
No response
Additional context
No response