diff --git a/packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/non-typeof/actual.js b/packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/non-typeof/actual.js new file mode 100644 index 0000000000..b637888826 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/non-typeof/actual.js @@ -0,0 +1,5 @@ +export default function (number) { + if (!isNaN(number)) { + return 1; + } +} diff --git a/packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/non-typeof/expected.js b/packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/non-typeof/expected.js new file mode 100644 index 0000000000..b637888826 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/non-typeof/expected.js @@ -0,0 +1,5 @@ +export default function (number) { + if (!isNaN(number)) { + return 1; + } +} diff --git a/packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/options.json b/packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/options.json new file mode 100644 index 0000000000..a9b95ca6a3 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["transform-es2015-typeof-symbol"] +} diff --git a/packages/babel-plugin-transform-es2015-typeof-symbol/src/index.js b/packages/babel-plugin-transform-es2015-typeof-symbol/src/index.js index a3da0e6267..08df2600a8 100644 --- a/packages/babel-plugin-transform-es2015-typeof-symbol/src/index.js +++ b/packages/babel-plugin-transform-es2015-typeof-symbol/src/index.js @@ -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