Fix numeric separator Number transform (#5825)
This commit is contained in:
committed by
Henry Zhu
parent
123dce5fcd
commit
8df5514083
@@ -1,15 +1,20 @@
|
||||
import syntaxNumericSeparator from "babel-plugin-syntax-numeric-separator";
|
||||
|
||||
export default function () {
|
||||
export default function ({ types: t }) {
|
||||
|
||||
function replacer(value) {
|
||||
return value.replace(/_/g, "");
|
||||
}
|
||||
|
||||
function replaceNumberArg({ node }) {
|
||||
if (node.callee.name === "Number") {
|
||||
node.arguments[0].value = replacer(node.arguments[0].value);
|
||||
if (node.callee.name !== "Number") {
|
||||
return;
|
||||
}
|
||||
const arg = node.arguments[0];
|
||||
if (!t.isStringLiteral(arg)) {
|
||||
return;
|
||||
}
|
||||
arg.value = replacer(arg.value);
|
||||
}
|
||||
|
||||
const CallExpression = replaceNumberArg;
|
||||
|
||||
Reference in New Issue
Block a user