Skip to content

Commit ca07dca

Browse files
committed
chore: remove type assertion in getArgsWithoutWaiterConfig
1 parent 538670b commit ca07dca

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ import type { ObjectExpression, ObjectProperty, Property } from "jscodeshift";
22

33
import { OBJECT_PROPERTY_TYPE_LIST } from "../config";
44

5-
export const getArgsWithoutWaiterConfig = <T>(callArgument: T): T => {
6-
if ((callArgument as ObjectExpression).type !== "ObjectExpression") {
7-
return callArgument;
8-
}
9-
10-
const objectExpression = callArgument as ObjectExpression;
11-
objectExpression.properties = objectExpression.properties.filter((property) => {
5+
export const getArgsWithoutWaiterConfig = (options: ObjectExpression): ObjectExpression => {
6+
options.properties = options.properties.filter((property) => {
127
if (!OBJECT_PROPERTY_TYPE_LIST.includes(property.type)) {
138
return true;
149
}
@@ -22,6 +17,5 @@ export const getArgsWithoutWaiterConfig = <T>(callArgument: T): T => {
2217
return true;
2318
});
2419

25-
// @ts-expect-error Type 'ObjectExpression' is not assignable to type 'T'.
26-
return objectExpression;
20+
return options;
2721
};

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@ export const replaceWaiterApi = (
5454
})
5555
);
5656

57+
const options = callExpression.node.arguments[1];
58+
const updatedOptions =
59+
options.type === "ObjectExpression" ? getArgsWithoutWaiterConfig(options) : options;
5760
return j.callExpression(j.identifier(getV3ClientWaiterApiName(waiterState)), [
5861
j.objectExpression(properties),
59-
getArgsWithoutWaiterConfig(callExpression.node.arguments[1]),
62+
updatedOptions,
6063
]);
6164
});
6265
}

0 commit comments

Comments
 (0)