diff --git a/src/coupon-cell/index.tsx b/src/coupon-cell/index.tsx index 87a9c1aa1..86e3b3d59 100644 --- a/src/coupon-cell/index.tsx +++ b/src/coupon-cell/index.tsx @@ -27,12 +27,13 @@ function formatValue(props: CouponCellProps) { if (coupon) { let value = 0; + if (isDef(coupon.value)) { ({ value } = coupon); } if (isDef(coupon.denominations)) { - value = coupon.denominations!; + value = coupon.denominations; } return `-${currency} ${(value / 100).toFixed(2)}`; diff --git a/src/utils/index.ts b/src/utils/index.ts index 83f5ff38b..6386cc111 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -9,7 +9,7 @@ export const isServer: boolean = Vue.prototype.$isServer; // eslint-disable-next-line @typescript-eslint/no-empty-function export function noop() {} -export function isDef(val: unknown): boolean { +export function isDef(val: T): val is NonNullable { return val !== undefined && val !== null; }