Skip to content

Commit 8c78d7e

Browse files
committed
chore: remove type assertion in addNamedModule
1 parent f5ab6b1 commit 8c78d7e

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/transforms/v2-to-v3/modules/requireModule/addNamedModule.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { Collection, JSCodeshift, ObjectPattern, ObjectProperty, Property } from "jscodeshift";
1+
import type { Collection, JSCodeshift, ObjectPattern } from "jscodeshift";
22

3-
import { OBJECT_PROPERTY_TYPE_LIST, PACKAGE_NAME } from "../../config";
3+
import { PACKAGE_NAME } from "../../config";
44
import { objectPatternPropertyCompareFn } from "../objectPatternPropertyCompareFn";
55
import { getRequireDeclarators } from "../requireModule";
66
import type { ModulesOptions } from "../types";
@@ -30,13 +30,11 @@ export const addNamedModule = (
3030
(variableDeclarator) =>
3131
variableDeclarator.id.type === "ObjectPattern" &&
3232
variableDeclarator.id.properties.find((property) => {
33-
if (!OBJECT_PROPERTY_TYPE_LIST.includes(property.type)) return false;
34-
const key = (property as Property | ObjectProperty).key;
35-
const value = (property as Property | ObjectProperty).value;
36-
if (key.type !== "Identifier" || value.type !== "Identifier") {
33+
if (property.type !== "Property" && property.type !== "ObjectProperty") return false;
34+
if (property.key.type !== "Identifier" || property.value.type !== "Identifier") {
3735
return false;
3836
}
39-
return key.name === importedName && value.name === localName;
37+
return property.key.name === importedName && property.value.name === localName;
4038
})
4139
)
4240
) {

0 commit comments

Comments
 (0)