Skip to content

Commit

Permalink
codemod: do not await on invalid prop (#71089)
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi authored Oct 10, 2024
1 parent f5d6b26 commit d9a9a5d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export async function GET(
req: NextRequest,
ctx: any,
): Promise<Response> {
callback(ctx.propDoesNotExist);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export async function GET(
req: NextRequest,
ctx: any,
): Promise<Response> {
callback(ctx.propDoesNotExist);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ function awaitMemberAccessOfProp(
memberAccess.forEach((memberAccessPath) => {
const member = memberAccessPath.value

const memberProperty = member.property
const isAccessingMatchedProperty =
j.Identifier.check(memberProperty) &&
TARGET_PROP_NAMES.has(memberProperty.name)

if (!isAccessingMatchedProperty) {
return
}

if (isParentPromiseAllCallExpression(memberAccessPath, j)) {
return
}
Expand Down

0 comments on commit d9a9a5d

Please sign in to comment.