小编You*_*MEL的帖子

Try/Catch/Finnaly with ESLint 预期在异步箭头函数结束时返回一个值

我的代码中有这个 ESLint 错误:

function(productId: any): Promise 预期在异步箭头函数结束时返回一个值

export const getGooglePlayPayment = async (productId) => {
  await InAppBilling.close();
  try {
    await InAppBilling.open();

    if (!await InAppBilling.isSubscribed(productId)) {
      const details = await InAppBilling.subscribe(productId);
      console.log('You purchased: ', details);
      return details.purchaseState === PAYMENT_STATE.PurchasedSuccessfully;
    }
  } catch (err) {
    console.log(err);
    return false;
  } finally {
    await InAppBilling.consumePurchase(productId);
    await InAppBilling.close();
  }
};
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题,而不必禁用 ESLing 规则:)

谢谢

javascript try-catch eslint arrow-functions

3
推荐指数
1
解决办法
2752
查看次数

标签 统计

arrow-functions ×1

eslint ×1

javascript ×1

try-catch ×1