Merge pull request #2866 from hzoo/i-2865

transform-es2015-typeof-symbol: check for undefined - fixes #2865
This commit is contained in:
Sebastian McKenzie
2015-11-06 19:40:21 -05:00
4 changed files with 14 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
export default function (number) {
if (!isNaN(number)) {
return 1;
}
}

View File

@@ -0,0 +1,5 @@
export default function (number) {
if (!isNaN(number)) {
return 1;
}
}

View File

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

View File

@@ -6,7 +6,7 @@ export default function ({ types: t }) {
UnaryExpression(path) {
let { node, parent } = path;
if (node[IGNORE]) return;
if (path.find(path => !!path.node._generated)) return;
if (path.find(path => path.node && !!path.node._generated)) return;
if (path.parentPath.isBinaryExpression() && t.EQUALITY_BINARY_OPERATORS.indexOf(parent.operator) >= 0) {
// optimise `typeof foo === "string"` since we can determine that they'll never need to handle symbols