From 46992ded7812a722d8e737500313190af8ca15c7 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Fri, 9 Aug 2024 00:58:47 +0800 Subject: [PATCH] fix: handle await detection in method property (#53) --- src/find.spec.ts | 13 +++++++++++++ src/find.ts | 1 + 2 files changed, 14 insertions(+) diff --git a/src/find.spec.ts b/src/find.spec.ts index 3faf4b9..7d1eed3 100644 --- a/src/find.spec.ts +++ b/src/find.spec.ts @@ -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(); + } + } + ` + ); + }); }); diff --git a/src/find.ts b/src/find.ts index 7970d21..d21a706 100644 --- a/src/find.ts +++ b/src/find.ts @@ -33,6 +33,7 @@ class FindPatternsVisitor extends Visitor { hook("visitClass"); hook("visitArrowFunctionExpression"); hook("visitFunction"); + hook("visitMethodProperty"); } visitAwaitExpression(expr: SWC.AwaitExpression): SWC.Expression {