Skip to content

Commit

Permalink
fix: handle await detection in method property (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Aug 8, 2024
1 parent 8006241 commit 46992de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/find.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,17 @@ describe("Find top-level await usage in module", () => {
`
);
});

it("should work with await in object method property", () => {
test(
null,
`
const obj = {
async method() {
await x.func();
}
}
`
);
});
});
1 change: 1 addition & 0 deletions src/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class FindPatternsVisitor extends Visitor {
hook("visitClass");
hook("visitArrowFunctionExpression");
hook("visitFunction");
hook("visitMethodProperty");
}

visitAwaitExpression(expr: SWC.AwaitExpression): SWC.Expression {
Expand Down

0 comments on commit 46992de

Please sign in to comment.