diff --git a/packages/js/data/src/countries/actions.ts b/packages/js/data/src/countries/actions.ts index 51cc2e19832..7970d6bfd2e 100644 --- a/packages/js/data/src/countries/actions.ts +++ b/packages/js/data/src/countries/actions.ts @@ -3,7 +3,6 @@ */ import TYPES from './action-types'; import { Locales, Country } from './types'; -import { RestApiError } from '../types'; export function getLocalesSuccess( locales: Locales ) { return { @@ -12,7 +11,7 @@ export function getLocalesSuccess( locales: Locales ) { }; } -export function getLocalesError( error: RestApiError ) { +export function getLocalesError( error: unknown ) { return { type: TYPES.GET_LOCALES_ERROR as const, error, @@ -26,7 +25,7 @@ export function getCountriesSuccess( countries: Country[] ) { }; } -export function getCountriesError( error: RestApiError ) { +export function getCountriesError( error: unknown ) { return { type: TYPES.GET_COUNTRIES_ERROR as const, error, diff --git a/packages/js/data/src/countries/resolvers.ts b/packages/js/data/src/countries/resolvers.ts index 6a384500de7..ccdb261276e 100644 --- a/packages/js/data/src/countries/resolvers.ts +++ b/packages/js/data/src/countries/resolvers.ts @@ -16,7 +16,6 @@ import { import { NAMESPACE } from '../constants'; import { Locales, Country } from './types'; import { STORE_NAME } from './constants'; -import { RestApiError } from '../types'; const resolveSelect = controls && controls.resolveSelect ? controls.resolveSelect : select; @@ -35,7 +34,7 @@ export function* getLocales() { return getLocalesSuccess( results ); } catch ( error ) { - return getLocalesError( error as RestApiError ); + return getLocalesError( error ); } } @@ -53,6 +52,6 @@ export function* getCountries() { return getCountriesSuccess( results ); } catch ( error ) { - return getCountriesError( error as RestApiError ); + return getCountriesError( error ); } } diff --git a/packages/js/data/src/countries/types.ts b/packages/js/data/src/countries/types.ts index ae90b880a00..467e561fbeb 100644 --- a/packages/js/data/src/countries/types.ts +++ b/packages/js/data/src/countries/types.ts @@ -41,7 +41,7 @@ export type Locales = { export type CountriesState = { errors: { - [ key: string ]: string | RestApiError | undefined; + [ key: string ]: unknown; }; locales: Locales; countries: Country[]; diff --git a/packages/js/data/src/payment-gateways/actions.ts b/packages/js/data/src/payment-gateways/actions.ts index 8b51ec211a9..afed637d2d8 100644 --- a/packages/js/data/src/payment-gateways/actions.ts +++ b/packages/js/data/src/payment-gateways/actions.ts @@ -9,7 +9,6 @@ import { apiFetch } from '@wordpress/data-controls'; import { ACTION_TYPES } from './action-types'; import { API_NAMESPACE } from './constants'; import { PaymentGateway } from './types'; -import { RestApiError } from '../types'; export function getPaymentGatewaysRequest(): { type: ACTION_TYPES.GET_PAYMENT_GATEWAYS_REQUEST; @@ -32,10 +31,10 @@ export function getPaymentGatewaysSuccess( } export function getPaymentGatewaysError( - error: RestApiError + error: unknown ): { type: ACTION_TYPES.GET_PAYMENT_GATEWAYS_ERROR; - error: RestApiError; + error: unknown; } { return { type: ACTION_TYPES.GET_PAYMENT_GATEWAYS_ERROR, @@ -52,10 +51,10 @@ export function getPaymentGatewayRequest(): { } export function getPaymentGatewayError( - error: RestApiError + error: unknown ): { type: ACTION_TYPES.GET_PAYMENT_GATEWAY_ERROR; - error: RestApiError; + error: unknown; } { return { type: ACTION_TYPES.GET_PAYMENT_GATEWAY_ERROR, @@ -95,10 +94,10 @@ export function updatePaymentGatewayRequest(): { } export function updatePaymentGatewayError( - error: RestApiError + error: unknown ): { type: ACTION_TYPES.UPDATE_PAYMENT_GATEWAY_ERROR; - error: RestApiError; + error: unknown; } { return { type: ACTION_TYPES.UPDATE_PAYMENT_GATEWAY_ERROR, @@ -127,7 +126,7 @@ export function* updatePaymentGateway( return response; } } catch ( e ) { - yield updatePaymentGatewayError( e as RestApiError ); + yield updatePaymentGatewayError( e ); throw e; } } diff --git a/packages/js/data/src/payment-gateways/resolvers.ts b/packages/js/data/src/payment-gateways/resolvers.ts index 13d763c7a2a..c345249279f 100644 --- a/packages/js/data/src/payment-gateways/resolvers.ts +++ b/packages/js/data/src/payment-gateways/resolvers.ts @@ -21,7 +21,6 @@ import { import { API_NAMESPACE, STORE_KEY } from './constants'; import { PaymentGateway } from './types'; -import { RestApiError } from '../types'; // Can be removed in WP 5.9. const dispatch = @@ -44,7 +43,7 @@ export function* getPaymentGateways() { ); } } catch ( e ) { - yield getPaymentGatewaysError( e as RestApiError ); + yield getPaymentGatewaysError( e ); } } @@ -61,6 +60,6 @@ export function* getPaymentGateway( id: string ) { return response; } } catch ( e ) { - yield getPaymentGatewayError( e as RestApiError ); + yield getPaymentGatewayError( e ); } } diff --git a/packages/js/data/src/payment-gateways/selectors.ts b/packages/js/data/src/payment-gateways/selectors.ts index df7bc7f2e9f..ee45abe0f47 100644 --- a/packages/js/data/src/payment-gateways/selectors.ts +++ b/packages/js/data/src/payment-gateways/selectors.ts @@ -2,7 +2,7 @@ * Internal dependencies */ import { PaymentGateway, PluginsState } from './types'; -import { RestApiError, WPDataSelector, WPDataSelectors } from '../types'; +import { WPDataSelector, WPDataSelectors } from '../types'; export function getPaymentGateway( state: PluginsState, @@ -22,7 +22,7 @@ export function getPaymentGateways( export function getPaymentGatewayError( state: PluginsState, selector: string -): RestApiError | null { +): unknown | null { return state.errors[ selector ] || null; } diff --git a/packages/js/data/src/payment-gateways/test/reducer.ts b/packages/js/data/src/payment-gateways/test/reducer.ts index 293e7f91798..075116be6a3 100644 --- a/packages/js/data/src/payment-gateways/test/reducer.ts +++ b/packages/js/data/src/payment-gateways/test/reducer.ts @@ -18,9 +18,6 @@ const defaultState: PluginsState = { const restApiError = { code: 'error code', - data: { - status: 400, - }, message: 'error message', }; diff --git a/packages/js/data/src/payment-gateways/types.ts b/packages/js/data/src/payment-gateways/types.ts index 17c23c966a0..24393e9e537 100644 --- a/packages/js/data/src/payment-gateways/types.ts +++ b/packages/js/data/src/payment-gateways/types.ts @@ -1,7 +1,6 @@ /** * Internal dependencies */ -import { RestApiError } from '../types'; export type SettingDefinition = { default: string; @@ -31,5 +30,5 @@ export type PaymentGateway = { export type PluginsState = { paymentGateways: PaymentGateway[]; isUpdating: boolean; - errors: Record< string, RestApiError >; + errors: Record< string, unknown >; };