* Import Currency type from correct location

* Add type for productPriceValidation argument

* Default tabIndex to undefined

null is not an acceptable value for the tabIndex prop, but undefined is, so we should use that.

* Explicitly set type of CartLineItemRow to ForwardRefExoticComponent

* bot: update checkstyle.xml

* Change CartLineItemRow to extend React.RefAttributes

* bot: update checkstyle.xml

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Thomas Roberts 2022-11-09 10:26:28 +00:00 committed by GitHub
parent 9ae1f91440
commit 6252b951e3
2 changed files with 8 additions and 15 deletions

View File

@ -19,10 +19,7 @@ import {
ProductMetadata,
ProductSaleBadge,
} from '@woocommerce/base-components/cart-checkout';
import {
getCurrencyFromPriceResponse,
Currency,
} from '@woocommerce/price-format';
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
import {
__experimentalApplyCheckoutFilter,
mustContain,
@ -30,7 +27,7 @@ import {
import Dinero from 'dinero.js';
import { forwardRef, useMemo } from '@wordpress/element';
import type { CartItem } from '@woocommerce/type-defs/cart';
import { objectHasProp } from '@woocommerce/types';
import { objectHasProp, Currency } from '@woocommerce/types';
import { getSetting } from '@woocommerce/settings';
/**
@ -47,7 +44,8 @@ const getAmountFromRawPrice = (
return priceObject.convertPrecision( currency.minorUnit ).getAmount();
};
const productPriceValidation = ( value ) => mustContain( value, '<price/>' );
const productPriceValidation = ( value: string ) =>
mustContain( value, '<price/>' );
interface CartLineItemRowProps {
lineItem: CartItem | Record< string, never >;
@ -58,9 +56,11 @@ interface CartLineItemRowProps {
/**
* Cart line item table row component.
*/
const CartLineItemRow = forwardRef< HTMLTableRowElement, CartLineItemRowProps >(
const CartLineItemRow: React.ForwardRefExoticComponent<
CartLineItemRowProps & React.RefAttributes< HTMLTableRowElement >
> = forwardRef< HTMLTableRowElement, CartLineItemRowProps >(
(
{ lineItem, onRemove = () => void null, tabIndex = null },
{ lineItem, onRemove = () => void null, tabIndex },
ref
): JSX.Element => {
const {
@ -367,5 +367,4 @@ const CartLineItemRow = forwardRef< HTMLTableRowElement, CartLineItemRowProps >(
);
}
);
export default CartLineItemRow;

View File

@ -2369,12 +2369,6 @@
Argument of type &apos;{ icon: { src: JSX.Element; }; edit: ({ clientId }: Props) =&gt; JSX.Element; save: () =&gt; JSX.Element; }&apos; is not assignable to parameter of type &apos;BlockConfiguration&lt;{}&gt;&apos;.
Type &apos;{ icon: { src: Element; }; edit: ({ clientId }: Props) =&gt; Element; save: () =&gt; Element; }&apos; is missing the following properties from type &apos;Pick&lt;Block&lt;{}&gt;, &quot;title&quot; | &quot;category&quot; | &quot;attributes&quot;&gt;&apos;: title, category, attributes" source="TS2769" />
</file>
<file name="assets/js/blocks/cart/cart-line-items-table/cart-line-item-row.tsx">
<error line="24" column="2" severity="error" message="Module &apos;&quot;@woocommerce/price-format&quot;&apos; has no exported member &apos;Currency&apos;." source="TS2305" />
<error line="50" column="34" severity="error" message="Parameter &apos;value&apos; implicitly has an &apos;any&apos; type." source="TS7006" />
<error line="215" column="5" severity="error" message="Type &apos;number | null&apos; is not assignable to type &apos;number | undefined&apos;.
Type &apos;null&apos; is not assignable to type &apos;number | undefined&apos;." source="TS2322" />
</file>
<file name="assets/js/blocks/cart/inner-blocks/cart-line-items-block/index.tsx">
<error line="12" column="1" severity="error" message="No overload matches this call.
Overload 1 of 2, &apos;(metadata: BlockConfiguration&lt;{ className: string; }&gt;, settings?: Partial&lt;BlockConfiguration&lt;{ className: string; }&gt;&gt; | undefined): Block&lt;...&gt; | undefined&apos;, gave the following error.