Skip to content

Commit

Permalink
Remove type assertion for TryStatement (#931)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Aug 8, 2024
1 parent 07e2379 commit 49ff721
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-cycles-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Remove type assertion for TryStatement
3 changes: 1 addition & 2 deletions src/transforms/v2-to-v3/apis/renameErrorCodeWithName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {
Collection,
FunctionExpression,
JSCodeshift,
TryStatement,
} from "jscodeshift";

import type { ClientIdentifier } from "../types";
Expand Down Expand Up @@ -59,7 +58,7 @@ export const renameErrorCodeWithName = (

// Replace error.code with error.name in try-catch clauses.
callExpressions.forEach((callExpression) => {
const tryStatement = j(callExpression).closest(j.TryStatement).nodes()[0] as TryStatement;
const tryStatement = j(callExpression).closest(j.TryStatement).nodes()[0];

if (!tryStatement || !tryStatement.handler) {
return;
Expand Down

0 comments on commit 49ff721

Please sign in to comment.