Fix transform-simplify-comparison-operators plugin
This commit is contained in:
parent
72f384bb29
commit
44e64c41f8
@ -0,0 +1,7 @@
|
||||
typeof 1 === "number";
|
||||
typeof 1 !== "string";
|
||||
|
||||
typeof 1 == "number";
|
||||
typeof 1 != "string";
|
||||
|
||||
a > b;
|
||||
@ -0,0 +1,7 @@
|
||||
typeof 1 == "number";
|
||||
typeof 1 != "string";
|
||||
|
||||
typeof 1 == "number";
|
||||
typeof 1 != "string";
|
||||
|
||||
a > b;
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["transform-simplify-comparison-operators"]
|
||||
}
|
||||
@ -1,12 +1,13 @@
|
||||
export default function () {
|
||||
return {
|
||||
visitor: {
|
||||
BinaryExpression(node) {
|
||||
let op = node.operator;
|
||||
BinaryExpression(path) {
|
||||
let { node, op } = path;
|
||||
|
||||
if (op !== "===" && op !== "!==") return;
|
||||
|
||||
let left = this.get("left");
|
||||
let right = this.get("right");
|
||||
let left = path.get("left");
|
||||
let right = path.get("right");
|
||||
if (left.baseTypeStrictlyMatches(right)) {
|
||||
node.operator = node.operator.slice(0, -1);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user