Fix TypeScript errors in `CartLineItemRow` (https://github.com/woocommerce/woocommerce-blocks/pull/7605)
* 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:
parent
9ae1f91440
commit
6252b951e3
|
@ -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;
|
||||
|
|
|
@ -2369,12 +2369,6 @@
|
|||
Argument of type '{ icon: { src: JSX.Element; }; edit: ({ clientId }: Props) => JSX.Element; save: () => JSX.Element; }' is not assignable to parameter of type 'BlockConfiguration<{}>'.
|
||||
Type '{ icon: { src: Element; }; edit: ({ clientId }: Props) => Element; save: () => Element; }' is missing the following properties from type 'Pick<Block<{}>, "title" | "category" | "attributes">': 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 '"@woocommerce/price-format"' has no exported member 'Currency'." source="TS2305" />
|
||||
<error line="50" column="34" severity="error" message="Parameter 'value' implicitly has an 'any' type." source="TS7006" />
|
||||
<error line="215" column="5" severity="error" message="Type 'number | null' is not assignable to type 'number | undefined'.
|
||||
Type 'null' is not assignable to type 'number | undefined'." 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, '(metadata: BlockConfiguration<{ className: string; }>, settings?: Partial<BlockConfiguration<{ className: string; }>> | undefined): Block<...> | undefined', gave the following error.
|
||||
|
|
Loading…
Reference in New Issue