Merge pull request #3250 from babel/symbol-rename

[T6933] Rename any shadowing Symbol binding
This commit is contained in:
Amjad Masad 2016-01-12 17:02:16 -08:00
commit b7aa49d9f5
4 changed files with 19 additions and 0 deletions

View File

@ -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;

View File

@ -0,0 +1,3 @@
var Symbol = foo();
typeof s;
foo(Symbol);

View File

@ -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);

View File

@ -0,0 +1,3 @@
{
"plugins": ["transform-es2015-typeof-symbol"]
}