Merge pull request #2866 from hzoo/i-2865
transform-es2015-typeof-symbol: check for undefined - fixes #2865
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
export default function (number) {
|
||||
if (!isNaN(number)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export default function (number) {
|
||||
if (!isNaN(number)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
3
packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/options.json
vendored
Normal file
3
packages/babel-core/test/fixtures/transformation/transform-es2015-typeof-symbol/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-es2015-typeof-symbol"]
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user