mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
types: improve isDef typing (#7124)
* types: improve isDef typing * chore: update
This commit is contained in:
parent
afe4248799
commit
c7303786ae
@ -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)}`;
|
||||
|
@ -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<T>(val: T): val is NonNullable<T> {
|
||||
return val !== undefined && val !== null;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user