Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
4819ea4
Update packages to pre- react 18 versions
tyxla Feb 28, 2023
1e7cf25
Noop some type packages with stale @wordpress/data module declarations
tyxla Feb 28, 2023
88e7597
Fix some TS errors
tyxla Feb 9, 2023
afb5603
Fix some unit tests
tyxla Feb 9, 2023
a63151a
Fix TS errors in wpcom-checkout
tyxla Feb 9, 2023
266cc23
Fix more TS errors
tyxla Feb 13, 2023
ba554bb
Fix TS errors in wpcom-plans-ui data store
tyxla Feb 28, 2023
868db66
Fix a bunch of other TS errors
tyxla Feb 13, 2023
2760aa8
Fix a bunch of other TS errors
tyxla Feb 13, 2023
bb07c00
Fix a bunch more TS errors
tyxla Feb 13, 2023
97bdf7f
Fix type confusion
tyxla Feb 13, 2023
990750a
Add core/data temp placeholder types
tyxla Feb 13, 2023
6b1ac77
deduplicate packages
tyxla Feb 28, 2023
787a9f2
Ignore some logs
tyxla Feb 28, 2023
2fd2d15
Fix another failing test
tyxla Feb 14, 2023
0684633
Fix a couple more tests
tyxla Feb 14, 2023
b8e4a20
Fix a bad import
tyxla Feb 14, 2023
39c8d53
Force @wordpress/element resolution
tyxla Feb 28, 2023
3070be4
Fix more code style errors
tyxla Feb 23, 2023
3f7ba02
Fix some code style errors
tyxla Feb 23, 2023
684a109
Declare TS modules of the nooped types
tyxla Feb 28, 2023
c6ffa97
Pin @wordpress/data-controls version
tyxla Feb 28, 2023
5489d74
Fix a ton of ETK TS errors
tyxla Mar 2, 2023
62fc636
Remove some undesired obsolete type packages
tyxla Mar 2, 2023
0131606
Restore @wordpress/data-controls types
tyxla Mar 2, 2023
6aca0fd
Add necessary @wordpress/blocks types inline
tyxla Mar 2, 2023
9254527
Remove a duplicate __i18n_text_domain__
tyxla Mar 2, 2023
3fd901e
Dedupe again
tyxla Mar 2, 2023
ebc0e59
Revert "Remove a duplicate __i18n_text_domain__"
tyxla Mar 2, 2023
ec4d5a6
Workaround a __i18n_text_domain__ duplication
tyxla Mar 2, 2023
bb7139d
Fix a bunch of store and checkout TS errors
tyxla Mar 2, 2023
9487ea0
Fix more package TS errors
tyxla Mar 2, 2023
e684094
Start fixing some more TS errors
tyxla Mar 6, 2023
93bdb81
More TS fixes
tyxla Mar 7, 2023
e026b9e
Fix a bunch more TS errors
tyxla Mar 7, 2023
5971e49
More TS error fixes
tyxla Mar 7, 2023
80003b4
Fix some imports
tyxla Mar 7, 2023
217d151
More TS errors
tyxla Mar 7, 2023
25f49de
Fix bad import
tyxla Mar 7, 2023
effc4d7
A few more TS fixes
tyxla Mar 7, 2023
9c29f87
More TS errors fixed
tyxla Mar 7, 2023
ebb6b5d
Add @automattic/global-styles to tsconfig references
tyxla Mar 7, 2023
00f0469
Fix a few more type errors
tyxla Mar 7, 2023
cc70ca0
Fix a few more TS errors
tyxla Mar 7, 2023
a012406
Ignore another log entry
tyxla Mar 8, 2023
c88396f
Fix more TS errors
tyxla Mar 8, 2023
7e8bd30
Pin @wordpress/base-styles
tyxla Mar 8, 2023
2891422
Revert @wordpress/env upgrade
tyxla Mar 8, 2023
ed8ceb8
Add missing select dependency
noahtallen Mar 8, 2023
6b61059
Add missing data dependencies to useSelect calls
noahtallen Mar 8, 2023
11edb1a
Remove some now uneeded ts-ignore lines
noahtallen Mar 8, 2023
d740121
Polish some useSelect dependencies
tyxla Mar 9, 2023
3f2cac9
Polish another useSelect data dependency
noahtallen Mar 9, 2023
c5df3e5
Account for possibly undefined stores
noahtallen Mar 9, 2023
cd45678
Add more data dependencies to useSelect calls
noahtallen Mar 10, 2023
b8a0f10
Fix render loop caused by obj reference changing each render
noahtallen Mar 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Start fixing some more TS errors
  • Loading branch information
tyxla committed Mar 13, 2023
commit e6840948fd95f290ff523196574b9ae729ecfaee
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import TaxFields from 'calypso/my-sites/checkout/composite-checkout/components/t
import useCountryList from 'calypso/my-sites/checkout/composite-checkout/hooks/use-country-list';
import { CountrySpecificPaymentFields } from '../../components/country-specific-payment-fields';
import { CardFieldState } from './types';
import type { WpcomCreditCardSelectors } from './store';
import type { ManagedContactDetails } from '@automattic/wpcom-checkout';

export default function ContactFields( {
Expand All @@ -22,8 +23,9 @@ export default function ContactFields( {
const { formStatus } = useFormStatus();
const isDisabled = formStatus !== FormStatus.READY;
const countriesList = useCountryList();
const fields: CardFieldState = useSelect( ( select ) =>
select( 'wpcom-credit-card' ).getFields()
const fields: CardFieldState = useSelect(
( select ) => ( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).getFields(),
[]
);
const onChangeContactInfo = ( newInfo: ManagedContactDetails ) => {
setFieldValue( 'countryCode', newInfo.countryCode?.value ?? '' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
StripeFieldWrapper,
StripeErrorMessage,
} from './form-layout-components';
import type { WpcomCreditCardSelectors } from './store';
import type { StripeFieldChangeInput } from './types';
import type { StripeElementStyle } from '@stripe/stripe-js';

Expand All @@ -36,8 +37,9 @@ export default function CreditCardCvvField( {
const translate = useTranslate();
const { formStatus } = useFormStatus();
const isDisabled = formStatus !== FormStatus.READY;
const { cardCvc: cardCvcError } = useSelect( ( select ) =>
select( 'wpcom-credit-card' ).getCardDataErrors()
const { cardCvc: cardCvcError } = useSelect(
( select ) => ( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).getCardDataErrors(),
[]
);
const errorMessages = getErrorMessagesForField( 'cvv' );
const errorMessage = errorMessages?.length > 0 ? errorMessages[ 0 ] : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useSelect } from '@wordpress/data';
import { useTranslate } from 'i18n-calypso';
import { Input } from 'calypso/my-sites/domains/components/form';
import { Label, LabelText, StripeFieldWrapper, StripeErrorMessage } from './form-layout-components';
import type { WpcomCreditCardSelectors } from './store';
import type { StripeFieldChangeInput } from './types';
import type { StripeElementStyle } from '@stripe/stripe-js';

Expand All @@ -25,8 +26,9 @@ export default function CreditCardExpiryField( {
const translate = useTranslate();
const { formStatus } = useFormStatus();
const isDisabled = formStatus !== FormStatus.READY;
const { cardExpiry: cardExpiryError } = useSelect( ( select ) =>
select( 'wpcom-credit-card' ).getCardDataErrors()
const { cardExpiry: cardExpiryError } = useSelect(
( select ) => ( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).getCardDataErrors(),
[]
);
const errorMessages = getErrorMessagesForField( 'expiration-date' );
const errorMessage = errorMessages?.length > 0 ? errorMessages[ 0 ] : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import CreditCardExpiryField from './credit-card-expiry-field';
import CreditCardLoading from './credit-card-loading';
import CreditCardNumberField from './credit-card-number-field';
import { FieldRow, CreditCardFieldsWrapper, CreditCardField } from './form-layout-components';
import type { WpcomCreditCardSelectors } from './store';
import type { CardFieldState, StripeFieldChangeInput } from './types';

const StripeFields = styled.div`
Expand Down Expand Up @@ -47,11 +48,14 @@ export default function CreditCardFields( {
const { __ } = useI18n();
const theme = useTheme();
const [ isStripeFullyLoaded, setIsStripeFullyLoaded ] = useState( false );
const fields: CardFieldState = useSelect( ( select ) =>
select( 'wpcom-credit-card' ).getFields()
const fields: CardFieldState = useSelect(
( select ) => ( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).getFields(),
[]
);
const useForAllSubscriptions: boolean = useSelect( ( select ) =>
select( 'wpcom-credit-card' ).useForAllSubscriptions()
const useForAllSubscriptions: boolean = useSelect(
( select ) =>
( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).useForAllSubscriptions(),
[]
);
const getField = ( key: string ) => fields[ key ] || {};
const getFieldValue = ( key: string ) => getField( key ).value ?? '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useSelect } from '@wordpress/data';
import { useI18n } from '@wordpress/react-i18n';
import CreditCardNumberInput from 'calypso/components/upgrades/credit-card-number-input';
import { Label, LabelText, StripeFieldWrapper, StripeErrorMessage } from './form-layout-components';
import type { WpcomCreditCardSelectors } from './store';
import type { StripeFieldChangeInput } from './types';
import type { StripeElementStyle } from '@stripe/stripe-js';

Expand All @@ -27,9 +28,13 @@ export default function CreditCardNumberField( {
const { __ } = useI18n();
const { formStatus } = useFormStatus();
const isDisabled = formStatus !== FormStatus.READY;
const brand: string = useSelect( ( select ) => select( 'wpcom-credit-card' ).getBrand() );
const { cardNumber: cardNumberError } = useSelect( ( select ) =>
select( 'wpcom-credit-card' ).getCardDataErrors()
const brand: string = useSelect(
( select ) => ( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).getBrand(),
[]
);
const { cardNumber: cardNumberError } = useSelect(
( select ) => ( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).getCardDataErrors(),
[]
);
const errorMessages = getErrorMessagesForField( 'number' );
const errorMessage = errorMessages?.length > 0 ? errorMessages[ 0 ] : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useI18n } from '@wordpress/react-i18n';
import debugFactory from 'debug';
import { validatePaymentDetails } from 'calypso/lib/checkout/validation';
import { actions, selectors } from './store';
import type { WpcomCreditCardSelectors } from './store';
import type { CardFieldState, CardStoreType } from './types';
import type { ProcessPayment, LineItem } from '@automattic/composite-checkout';

Expand All @@ -28,11 +29,14 @@ export default function CreditCardPayButton( {
const { __ } = useI18n();
const total = useTotal();
const { stripeConfiguration, stripe } = useStripe();
const fields: CardFieldState = useSelect( ( select ) =>
select( 'wpcom-credit-card' ).getFields()
const fields: CardFieldState = useSelect(
( select ) => ( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).getFields(),
[]
);
const useForAllSubscriptions = useSelect( ( select ) =>
select( 'wpcom-credit-card' ).useForAllSubscriptions()
const useForAllSubscriptions = useSelect(
( select ) =>
( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).useForAllSubscriptions(),
[]
);
const cardholderName = fields.cardholderName;
const { formStatus } = useFormStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from 'calypso/my-sites/checkout/composite-checkout/components/summary-details';
import CreditCardFields from './credit-card-fields';
import CreditCardPayButton from './credit-card-pay-button';
import type { WpcomCreditCardSelectors } from './store';
import type { CardFieldState, CardStoreType } from './types';

export { createCreditCardPaymentMethodStore } from './store';
Expand Down Expand Up @@ -55,11 +56,15 @@ export function createCreditCardMethod( {
}

function CreditCardSummary() {
const fields: CardFieldState = useSelect( ( select ) =>
select( 'wpcom-credit-card' ).getFields()
const fields: CardFieldState = useSelect(
( select ) => ( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).getFields(),
[]
);
const cardholderName = fields.cardholderName;
const brand: string = useSelect( ( select ) => select( 'wpcom-credit-card' ).getBrand() );
const brand: string = useSelect(
( select ) => ( select( 'wpcom-credit-card' ) as WpcomCreditCardSelectors ).getBrand(),
[]
);

return (
<SummaryDetails>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import type {
CardStoreAction,
CardElementType,
} from './types';
import type { SelectFromMap } from '@automattic/data-stores';
import type { StoreStateValue } from '@automattic/wpcom-checkout';
import type { AnyAction } from 'redux';

const debug = debugFactory( 'calypso:composite-checkout:credit-card' );

Expand Down Expand Up @@ -56,6 +58,8 @@ export const selectors = {
},
};

export type WpcomCreditCardSelectors = SelectFromMap< typeof selectors >;

export function createCreditCardPaymentMethodStore( {
initialUseForAllSubscriptions,
allowUseForAllSubscriptions,
Expand Down Expand Up @@ -168,7 +172,7 @@ export function createCreditCardPaymentMethodStore( {
brand: brandReducer(),
useForAllSubscriptions: getInitialUseForAllSubscriptionsValue(),
},
action
action: AnyAction
) {
return {
fields: fieldReducer( state.fields, action ),
Expand Down