Skip to content

Commit 88390fe

Browse files
authored
refactor: updated additional components to TSX (#10832)
1 parent 320637c commit 88390fe

File tree

17 files changed

+80
-35
lines changed

17 files changed

+80
-35
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Significance: patch
2+
Type: dev
3+
Comment: chore: updated additional components to TSX
4+
5+

client/components/clickable-cell/test/index.js renamed to client/components/clickable-cell/__tests__/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { render } from '@testing-library/react';
88
/**
99
* Internal dependencies
1010
*/
11-
import ClickableCell from '../';
11+
import ClickableCell from '..';
1212

1313
describe( 'Clickable cell', () => {
1414
test( 'renders a clickable cell when a link is provided', () => {

client/components/clickable-cell/index.js renamed to client/components/clickable-cell/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,25 @@
33
/**
44
* External dependencies
55
*/
6+
import { Link } from '@woocommerce/components';
7+
import React, { ReactNode, ComponentProps } from 'react';
68

79
/**
810
* Internal dependencies
911
*/
1012
import './style.scss';
11-
import { Link } from '@woocommerce/components';
1213

13-
const ClickableCell = ( { href, children, ...linkProps } ) =>
14+
interface ClickableCellProps
15+
extends Omit< ComponentProps< typeof Link >, 'href' > {
16+
href?: string;
17+
children: ReactNode;
18+
}
19+
20+
const ClickableCell = ( {
21+
href,
22+
children,
23+
...linkProps
24+
}: ClickableCellProps ) =>
1425
href ? (
1526
<Link
1627
href={ href }
@@ -21,7 +32,7 @@ const ClickableCell = ( { href, children, ...linkProps } ) =>
2132
{ children }
2233
</Link>
2334
) : (
24-
children
35+
<>{ children }</>
2536
);
2637

2738
export default ClickableCell;

client/components/jetpack-idc-notice/index.js renamed to client/components/jetpack-idc-notice/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* External dependencies
33
*/
4+
import React from 'react';
45
import { __ } from '@wordpress/i18n';
56
import { Notice } from '@wordpress/components';
67

client/components/payment-method-details/index.js renamed to client/components/payment-method-details/index.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
/** @format **/
22

3+
/**
4+
* External dependencies
5+
*/
6+
import React, { Fragment, ReactNode } from 'react';
7+
38
/**
49
* Internal dependencies
510
*/
6-
import { Fragment } from 'react';
711
import './style.scss';
812
import p24BankList from '../../payment-details/payment-method/p24/bank-list';
913
import { HoverTooltip } from '../tooltip';
1014
import { getTransactionPaymentMethodTitle } from 'wcpay/transactions/utils/getTransactionPaymentMethodTitle';
1115

16+
interface Payment {
17+
type: string;
18+
[ key: string ]: any;
19+
}
20+
1221
/**
1322
*
14-
* @param {Object} payment Payment charge object
15-
* @return {ReactNode} Fragment containing formatted summary detail
23+
* @param payment Payment charge object
24+
* @return Fragment containing formatted summary detail
1625
*/
17-
const formatDetails = ( payment ) => {
26+
const formatDetails = ( payment: Payment ): ReactNode => {
1827
const paymentMethod = payment[ payment.type ];
1928
/**
2029
* FLAG: PAYMENT_METHODS_LIST
@@ -23,7 +32,7 @@ const formatDetails = ( payment ) => {
2332
* add it here. If not, you don't need to list it here.
2433
*
2534
* If you're removing a payment method, you'll probably want to leave this section
26-
* section alone because we still need to display the details of existing transactions.
35+
* alone because we still need to display the details of existing transactions.
2736
*/
2837
switch ( payment.type ) {
2938
case 'card':
@@ -58,8 +67,11 @@ const formatDetails = ( payment ) => {
5867
}
5968
};
6069

61-
const PaymentMethodDetails = ( props ) => {
62-
const { payment } = props;
70+
interface PaymentMethodDetailsProps {
71+
payment: Payment;
72+
}
73+
74+
const PaymentMethodDetails = ( { payment }: PaymentMethodDetailsProps ) => {
6375
const paymentMethod = payment ? payment[ payment.type ] : null;
6476

6577
if ( ! paymentMethod && ( ! payment || payment.type !== 'link' ) ) {

0 commit comments

Comments
 (0)