Skip to content

Commit

Permalink
chore: remove type assertion in getWaiterConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Jul 28, 2024
1 parent 52fc6ee commit 2d81813
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/transforms/v2-to-v3/apis/getWaiterConfig.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import type { ObjectExpression, ObjectProperty, Property } from "jscodeshift";

import { OBJECT_PROPERTY_TYPE_LIST } from "../config";
import type { ObjectExpression } from "jscodeshift";

export const getWaiterConfig = (originalConfig: ObjectExpression): ObjectExpression | undefined => {
for (const property of originalConfig.properties) {
if (!OBJECT_PROPERTY_TYPE_LIST.includes(property.type)) {
if (property.type !== "Property" && property.type !== "ObjectProperty") {
continue;
}
const propertyKey = (property as Property | ObjectProperty).key;
const propertyValue = (property as Property | ObjectProperty).value;
if (propertyKey.type !== "Identifier" || propertyValue.type !== "ObjectExpression") {
if (property.key.type !== "Identifier" || property.value.type !== "ObjectExpression") {
continue;
}
if (propertyKey.name === "$waiter") {
return propertyValue;
if (property.key.name === "$waiter") {
return property.value;
}
}
};

0 comments on commit 2d81813

Please sign in to comment.