Avoid exception when typeof is in anonymous function declaration.

This commit is contained in:
Logan Smyth 2017-09-26 12:55:58 -07:00
parent 8bea5f4f16
commit 9b0f509433
4 changed files with 14 additions and 1 deletions

View File

@ -33,7 +33,9 @@ export default function({ types: t }) {
const isUnderHelper = path.findParent(path => {
return (
(path.isVariableDeclarator() && path.node.id === helper) ||
(path.isFunctionDeclaration() && path.node.id.name === helper.name)
(path.isFunctionDeclaration() &&
path.node.id &&
path.node.id.name === helper.name)
);
});

View File

@ -0,0 +1,3 @@
export default function() {
typeof {} === "object";
}

View File

@ -0,0 +1,5 @@
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function (obj) { return typeof obj; }; } else { _typeof = function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
export default function () {
_typeof({}) === "object";
}

View File

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