【发布时间】:2019-10-17 11:28:37
【问题描述】:
我的代码中有这个 ESLint 错误:
function(productId: any): 承诺 期望在异步箭头函数结束时返回一个值
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();
}
};
有人可以帮我解决这个问题,而不必禁用 ESLing 规则 :)
谢谢
【问题讨论】:
-
在您的 try 块中,您在 if 中有返回类型,但是在外面呢?如果你的代码执行没有进入 if 块,try 块应该返回一些东西
-
我的回答解决了你的问题吗?
标签: javascript try-catch eslint arrow-functions