Skip to content

Commit ebb00f1

Browse files
committed
chore: remove type assertion in objectPatternPropertyCompareFn
1 parent ef2ebf0 commit ebb00f1

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/transforms/v2-to-v3/modules/objectPatternPropertyCompareFn.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import type {
77
SpreadPropertyPattern,
88
} from "jscodeshift";
99

10-
import { OBJECT_PROPERTY_TYPE_LIST } from "../config";
11-
1210
export type ObjectPatternProperty =
1311
| Property
1412
| PropertyPattern
@@ -21,14 +19,14 @@ export const objectPatternPropertyCompareFn = (
2119
property1: ObjectPatternProperty,
2220
property2: ObjectPatternProperty
2321
) => {
24-
if (
25-
OBJECT_PROPERTY_TYPE_LIST.includes(property1.type) &&
26-
OBJECT_PROPERTY_TYPE_LIST.includes(property2.type)
27-
) {
28-
const property1Key = (property1 as Property | ObjectProperty).key;
29-
const property2Key = (property2 as Property | ObjectProperty).key;
30-
if (property1Key.type === "Identifier" && property2Key.type === "Identifier")
31-
return property1Key.name.localeCompare(property2Key.name);
22+
if (property1.type !== "Property" && property1.type !== "ObjectProperty") {
23+
return 0;
24+
}
25+
if (property2.type !== "Property" && property2.type !== "ObjectProperty") {
26+
return 0;
27+
}
28+
if (property1.key.type === "Identifier" && property2.key.type === "Identifier") {
29+
return property1.key.name.localeCompare(property2.key.name);
3230
}
3331
return 0;
3432
};

0 commit comments

Comments
 (0)