diff --git a/lib/6to5/transformation/transformers/optional-undefined-to-void.js b/lib/6to5/transformation/transformers/optional-undefined-to-void.js new file mode 100644 index 0000000000..19875cd90a --- /dev/null +++ b/lib/6to5/transformation/transformers/optional-undefined-to-void.js @@ -0,0 +1,9 @@ +var t = require("../../types"); + +exports.optional = true; + +exports.Identifier = function (node, parent) { + if (node.name === "undefined" && t.isReferenced(node, parent)) { + return t.unaryExpression("void", t.literal(0), true); + } +};