summaryrefslogtreecommitdiff
path: root/node_modules/babel-plugin-transform-undefined-to-void/lib/index.js
blob: 6e9c1e09e86c9c2d6d9b5aae06afa3dac058ab1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"use strict";

module.exports = function ({
  types: t
}) {
  const VOID_0 = t.unaryExpression("void", t.numericLiteral(0), true);
  return {
    name: "transform-undefined-to-void",
    visitor: {
      ReferencedIdentifier(path) {
        if (path.node.name === "undefined") {
          path.replaceWith(VOID_0);
        }
      }

    }
  };
};