Skip to content

Commit d9d8e54

Browse files
committed
chore: remove type assertion in replaceS3GetSignedUrlApi
1 parent ce41877 commit d9d8e54

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

src/transforms/v2-to-v3/apis/replaceS3GetSignedUrlApi.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
import type {
2-
Collection,
3-
JSCodeshift,
4-
NewExpression,
5-
ObjectExpression,
6-
ObjectProperty,
7-
Property,
8-
} from "jscodeshift";
1+
import type { Collection, JSCodeshift, NewExpression, ObjectExpression } from "jscodeshift";
92

10-
import { OBJECT_PROPERTY_TYPE_LIST } from "../config";
113
import type { ClientIdentifier } from "../types";
124
import { getClientApiCallExpression } from "./getClientApiCallExpression";
135
import { getCommandName } from "./getCommandName";
@@ -41,26 +33,26 @@ export const replaceS3GetSignedUrlApi = (
4133
if (params.type === "ObjectExpression") {
4234
// Check if params has property 'Expires' and add it to options.
4335
for (const property of params.properties) {
44-
if (!OBJECT_PROPERTY_TYPE_LIST.includes(property.type)) continue;
45-
const propertyKey = (property as Property | ObjectProperty).key;
46-
const propertyValue = (property as Property | ObjectProperty).value;
47-
if (propertyKey.type === "Identifier") {
48-
const propertyKeyName = propertyKey.name;
49-
if (propertyKeyName === "Expires") {
36+
if (property.type !== "Property" && property.type !== "ObjectProperty") {
37+
continue;
38+
}
39+
if (property.key.type === "Identifier") {
40+
if (property.key.name === "Expires") {
5041
// Add 'expiresIn' property to options.
5142
options.properties.push(
5243
j.objectProperty.from({
5344
key: j.identifier("expiresIn"),
54-
value: propertyValue,
45+
value: property.value,
5546
shorthand: true,
5647
})
5748
);
5849
// Remove 'Expires' property from params.
5950
params.properties = params.properties.filter((property) => {
60-
if (!OBJECT_PROPERTY_TYPE_LIST.includes(property.type)) return true;
61-
const propertyKey = (property as Property | ObjectProperty).key;
62-
if (propertyKey.type !== "Identifier") return true;
63-
return propertyKey.name !== "Expires";
51+
if (property.type !== "Property" && property.type !== "ObjectProperty") {
52+
return true;
53+
}
54+
if (property.key.type !== "Identifier") return true;
55+
return property.key.name !== "Expires";
6456
});
6557
}
6658
}

0 commit comments

Comments
 (0)