Files
babel/packages/babel-plugin-transform-undefined-to-void/src/index.js

12 lines
261 B
JavaScript

export default function ({ types: t }) {
return {
visitor: {
ReferencedIdentifier(path) {
if (path.node.name === "undefined") {
path.replaceWith(t.unaryExpression("void", t.numericLiteral(0), true));
}
}
}
};
}