types(CouponCell): use tsx (#8089)

This commit is contained in:
neverland 2021-02-05 11:11:27 +08:00 committed by GitHub
parent 1b75c706ab
commit efa8c0e798
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,17 @@
import { PropType } from 'vue';
import { isDef, createNamespace } from '../utils'; import { isDef, createNamespace } from '../utils';
import type { CouponInfo } from '../coupon';
// Components
import Cell from '../cell'; import Cell from '../cell';
const [createComponent, bem, t] = createNamespace('coupon-cell'); const [createComponent, bem, t] = createNamespace('coupon-cell');
function formatValue(props) { function formatValue(
const { coupons, chosenCoupon, currency } = props; coupons: CouponInfo[],
chosenCoupon: number | string,
currency: string
) {
const coupon = coupons[+chosenCoupon]; const coupon = coupons[+chosenCoupon];
if (coupon) { if (coupon) {
@ -26,7 +33,7 @@ export default createComponent({
props: { props: {
title: String, title: String,
coupons: { coupons: {
type: Array, type: Array as PropType<CouponInfo[]>,
default: () => [], default: () => [],
}, },
currency: { currency: {
@ -50,7 +57,11 @@ export default createComponent({
setup(props) { setup(props) {
return () => { return () => {
const selected = props.coupons[+props.chosenCoupon]; const selected = props.coupons[+props.chosenCoupon];
const value = formatValue(props); const value = formatValue(
props.coupons,
props.chosenCoupon,
props.currency
);
return ( return (
<Cell <Cell