Merge pull request #3250 from babel/symbol-rename
[T6933] Rename any shadowing Symbol binding
This commit is contained in:
commit
b7aa49d9f5
@ -3,6 +3,14 @@ export default function ({ types: t }) {
|
||||
|
||||
return {
|
||||
visitor: {
|
||||
Scope({ scope }) {
|
||||
if (!scope.getBinding("Symbol")) {
|
||||
return;
|
||||
}
|
||||
|
||||
scope.rename("Symbol");
|
||||
},
|
||||
|
||||
UnaryExpression(path) {
|
||||
let { node, parent } = path;
|
||||
if (node[IGNORE]) return;
|
||||
|
||||
3
packages/babel-plugin-transform-es2015-typeof-symbol/test/fixtures/symbols/shadow/actual.js
vendored
Normal file
3
packages/babel-plugin-transform-es2015-typeof-symbol/test/fixtures/symbols/shadow/actual.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
var Symbol = foo();
|
||||
typeof s;
|
||||
foo(Symbol);
|
||||
@ -0,0 +1,5 @@
|
||||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
|
||||
|
||||
var _Symbol = foo();
|
||||
typeof s === "undefined" ? "undefined" : _typeof(s);
|
||||
foo(_Symbol);
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-es2015-typeof-symbol"]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user