Skip to content

Commit

Permalink
Make AwaitExpression/VariableDeclarator generic while removing .promi…
Browse files Browse the repository at this point in the history
…se() API (#403)
  • Loading branch information
trivikr authored Feb 23, 2023
1 parent 8653240 commit 13fd08a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-flowers-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Make AwaitExpression/VariableDeclarator generic while removing .promise() API
16 changes: 3 additions & 13 deletions src/transforms/v2-to-v3/apis/removePromiseForCallExpression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,17 @@ import { print } from "recast";

export const removePromiseForCallExpression = (callExpression: ASTPath<CallExpression>) => {
switch (callExpression.parentPath.value.type) {
case "AwaitExpression": {
callExpression.parentPath.value.argument = (
callExpression.value.callee as MemberExpression
).object;
break;
}
case "MemberExpression": {
callExpression.parentPath.value.object = (
callExpression.value.callee as MemberExpression
).object;
break;
}
case "VariableDeclarator": {
callExpression.parentPath.value.init = (
callExpression.value.callee as MemberExpression
).object;
break;
}
case "ArrowFunctionExpression":
case "AwaitExpression":
case "ObjectProperty":
case "ReturnStatement": {
case "ReturnStatement":
case "VariableDeclarator": {
const currentCalleeObject = (callExpression.value.callee as MemberExpression)
.object as CallExpression;
if (currentCalleeObject.arguments.length > 0) {
Expand Down

0 comments on commit 13fd08a

Please sign in to comment.