Commit f90abe3973e for woocommerce
commit f90abe3973ebe6fd3e3ded0dda07e26792d39d16
Author: Luigi Teschio <gigitux@gmail.com>
Date: Mon Nov 9 16:39:51 2026 +0100
Remove Redux type dependencies from @woocommerce/data (#70778)
* Declare redux and make core-data peer-only in @woocommerce/data
The published types import redux, so declare it as a dependency rather
than a dev dependency. Strict installers can then resolve the types.
@wordpress/core-data was declared as both a dependency and a peer, which
could install a second copy that registers the core store again. Keep
the peer, and add a dev dependency for local builds.
* Reapply @woocommerce/data lockfile entries after trunk merge
Move the redux and @wordpress/core-data importer entries for @woocommerce/data to match its manifest. Resolved versions are unchanged.
* Remove Redux type dependencies from WooCommerce data
* Update changelog for Redux-independent data declarations
---------
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
diff --git a/packages/js/data/changelog/fix-declare-redux-dependency b/packages/js/data/changelog/fix-declare-redux-dependency
new file mode 100644
index 00000000000..c2f6ce2f283
--- /dev/null
+++ b/packages/js/data/changelog/fix-declare-redux-dependency
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Remove direct Redux type imports so the published TypeScript types resolve without a Redux dependency.
diff --git a/packages/js/data/changelog/update-core-data-peer-only b/packages/js/data/changelog/update-core-data-peer-only
new file mode 100644
index 00000000000..25120a48da5
--- /dev/null
+++ b/packages/js/data/changelog/update-core-data-peer-only
@@ -0,0 +1,4 @@
+Significance: minor
+Type: update
+
+Stop installing a separate `@wordpress/core-data`; projects must install it as the peer dependency it already was.
diff --git a/packages/js/data/eslint.config.mjs b/packages/js/data/eslint.config.mjs
index 6c11e69e419..01e9eb4c55d 100644
--- a/packages/js/data/eslint.config.mjs
+++ b/packages/js/data/eslint.config.mjs
@@ -11,7 +11,6 @@ export default [
'import/core-modules': [
...coreModules,
'@wordpress/api-fetch',
- 'redux',
],
'import/resolver': {
node: {},
diff --git a/packages/js/data/package.json b/packages/js/data/package.json
index f7f4ddf9ae9..184f88a5bf1 100644
--- a/packages/js/data/package.json
+++ b/packages/js/data/package.json
@@ -69,7 +69,6 @@
"@woocommerce/tracks": "workspace:*",
"@wordpress/api-fetch": "catalog:wp-min",
"@wordpress/compose": "catalog:wp-min",
- "@wordpress/core-data": "catalog:wp-min",
"@wordpress/data-controls": "catalog:wp-min",
"@wordpress/deprecated": "catalog:wp-min",
"@wordpress/element": "catalog:wp-min",
@@ -111,14 +110,13 @@
"jest-environment-jsdom": "catalog:tooling",
"react": "18.3.x",
"react-dom": "18.3.x",
- "redux": "^4.2.1",
"rimraf": "catalog:tooling",
"ts-jest": "catalog:tooling",
"typescript": "catalog:tooling"
},
"peerDependencies": {
"@wordpress/data": "^10.19.0",
- "@wordpress/core-data": "^7.19.0",
+ "@wordpress/core-data": "catalog:wp-min",
"moment": "^2.18.1",
"react": "18.3.x",
"react-dom": "18.3.x"
diff --git a/packages/js/data/src/activity-panel/reducer.ts b/packages/js/data/src/activity-panel/reducer.ts
index 915655b00cc..562c4876c0c 100644
--- a/packages/js/data/src/activity-panel/reducer.ts
+++ b/packages/js/data/src/activity-panel/reducer.ts
@@ -1,8 +1,3 @@
-/**
- * External dependencies
- */
-import { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -10,10 +5,10 @@ import TYPES from './action-types';
import { Actions } from './actions';
import { ActivityPanelState } from './types';
-const reducer: Reducer< ActivityPanelState, Actions > = (
- state = {},
- payload
-) => {
+const reducer = (
+ state: ActivityPanelState = {},
+ payload: Actions
+): ActivityPanelState => {
if ( payload && 'type' in payload ) {
switch ( payload.type ) {
case TYPES.GET_ACTIVITY_PANEL_COUNTS_SUCCESS:
diff --git a/packages/js/data/src/controls.ts b/packages/js/data/src/controls.ts
index e886b62b8ae..db54014128c 100644
--- a/packages/js/data/src/controls.ts
+++ b/packages/js/data/src/controls.ts
@@ -3,7 +3,11 @@
*/
import { controls as dataControls } from '@wordpress/data-controls';
import apiFetch, { APIFetchOptions } from '@wordpress/api-fetch';
-import { AnyAction } from 'redux';
+
+/**
+ * Internal dependencies
+ */
+import type { AnyAction } from './crud/types';
export const fetchWithHeaders = (
options: APIFetchOptions
diff --git a/packages/js/data/src/countries/reducer.ts b/packages/js/data/src/countries/reducer.ts
index f95e1dffeb4..834a028dc0d 100644
--- a/packages/js/data/src/countries/reducer.ts
+++ b/packages/js/data/src/countries/reducer.ts
@@ -1,9 +1,3 @@
-/**
- * External dependencies
- */
-
-import type { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -11,15 +5,15 @@ import TYPES from './action-types';
import { Action } from './actions';
import { CountriesState } from './types';
-const reducer: Reducer< CountriesState, Action > = (
- state = {
+const reducer = (
+ state: CountriesState = {
errors: {},
locales: {},
countries: [],
geolocation: undefined,
},
- action
-) => {
+ action: Action
+): CountriesState => {
switch ( action.type ) {
case TYPES.GET_LOCALES_SUCCESS:
state = {
diff --git a/packages/js/data/src/crud/README.md b/packages/js/data/src/crud/README.md
index 6fbb949acf2..8c02b957150 100644
--- a/packages/js/data/src/crud/README.md
+++ b/packages/js/data/src/crud/README.md
@@ -196,7 +196,7 @@ export type MyCustomSelectors = CrudSelectors<
// index.ts
-import { Reducer } from 'redux';
+import type { AnyAction } from '../crud/types';
import { createCrudDataStore } from '../crud';
import { ResourceState } from '../crud/reducer';
import * as actions from './actions';
@@ -210,7 +210,7 @@ export const store = createCrudDataStore<MyCustomActions, MyCustomSelectors>({
pluralResourceName: 'MyCustomResources',
namespace: '/my/rest/namespace',
storeConfig: {
- reducer: reducer as Reducer<ResourceState>,
+ reducer: reducer as (state: ResourceState | undefined, action: AnyAction) => ResourceState,
actions: actions as MyCustomActions,
selectors: selectors as MyCustomSelectors,
},
diff --git a/packages/js/data/src/crud/index.ts b/packages/js/data/src/crud/index.ts
index b53333a9589..c94e16f6681 100644
--- a/packages/js/data/src/crud/index.ts
+++ b/packages/js/data/src/crud/index.ts
@@ -2,11 +2,11 @@
* External dependencies
*/
import { createReduxStore, register } from '@wordpress/data';
-import { AnyAction } from 'redux';
/**
* Internal dependencies
*/
+import type { AnyAction } from './types';
import { createSelectors } from './selectors';
import { createDispatchActions } from './actions';
import defaultControls from '../controls';
diff --git a/packages/js/data/src/crud/reducer.ts b/packages/js/data/src/crud/reducer.ts
index 1e425ef8efd..cbcc238065b 100644
--- a/packages/js/data/src/crud/reducer.ts
+++ b/packages/js/data/src/crud/reducer.ts
@@ -1,8 +1,3 @@
-/**
- * External dependencies
- */
-import { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -15,7 +10,7 @@ import {
} from './utils';
import { getTotalCountResourceName } from '../utils';
import { TYPES } from './action-types';
-import type { IdType, Item, ItemQuery } from './types';
+import type { AnyAction, IdType, Item, ItemQuery } from './types';
export type Data = Record< IdType, Item >;
export type ResourceState = {
@@ -32,18 +27,21 @@ export type ResourceState = {
};
export const createReducer = (
- additionalReducer?: Reducer< ResourceState >
+ additionalReducer?: (
+ state: ResourceState | undefined,
+ action: AnyAction
+ ) => ResourceState
) => {
- const reducer: Reducer< ResourceState, Actions > = (
- state = {
+ const reducer = (
+ state: ResourceState = {
items: {},
data: {},
itemsCount: {},
errors: {},
requesting: {},
},
- payload
- ) => {
+ payload: Actions
+ ): ResourceState => {
const itemData = state.data || {};
if ( payload && 'type' in payload ) {
diff --git a/packages/js/data/src/crud/types.ts b/packages/js/data/src/crud/types.ts
index e7a912afe43..9622d2b6dfd 100644
--- a/packages/js/data/src/crud/types.ts
+++ b/packages/js/data/src/crud/types.ts
@@ -13,6 +13,16 @@ import {
getItemUpdateError,
} from './selectors';
+/**
+ * A store action with arbitrary properties, compatible with existing Redux actions.
+ */
+export type AnyAction = {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ type: any;
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ [ extraProps: string ]: any;
+};
+
export type IdType = number | string;
export type IdQuery =
diff --git a/packages/js/data/src/export/index.ts b/packages/js/data/src/export/index.ts
index c2780d3605a..b364f549bdf 100644
--- a/packages/js/data/src/export/index.ts
+++ b/packages/js/data/src/export/index.ts
@@ -2,10 +2,10 @@
* External dependencies
*/
import { registerStore } from '@wordpress/data';
-import { Reducer, AnyAction } from 'redux';
/**
* Internal dependencies
*/
+import type { AnyAction } from '../crud/types';
import { STORE_NAME } from './constants';
import * as selectors from './selectors';
import * as actions from './actions';
@@ -18,7 +18,10 @@ export type { State };
// @ts-expect-error migrate store to createReduxStore function https://github.com/woocommerce/woocommerce/issues/55640
registerStore< State >( STORE_NAME, {
- reducer: reducer as Reducer< State, AnyAction >,
+ reducer: reducer as (
+ state: State | undefined,
+ action: AnyAction
+ ) => State,
actions,
controls,
selectors,
diff --git a/packages/js/data/src/export/reducer.ts b/packages/js/data/src/export/reducer.ts
index 9e2f1102107..e080b89c76b 100644
--- a/packages/js/data/src/export/reducer.ts
+++ b/packages/js/data/src/export/reducer.ts
@@ -1,9 +1,3 @@
-/**
- * External dependencies
- */
-
-import type { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -12,15 +6,15 @@ import { Action } from './actions';
import { hashExportArgs } from './utils';
import { ExportState } from './types';
-const reducer: Reducer< ExportState, Action > = (
- state = {
+const reducer = (
+ state: ExportState = {
errors: {},
requesting: {},
exportMeta: {},
exportIds: {},
},
- action
-) => {
+ action: Action
+): ExportState => {
switch ( action.type ) {
case TYPES.SET_IS_REQUESTING:
return {
diff --git a/packages/js/data/src/import/index.ts b/packages/js/data/src/import/index.ts
index e45bd5b3262..1b4530821e1 100644
--- a/packages/js/data/src/import/index.ts
+++ b/packages/js/data/src/import/index.ts
@@ -3,10 +3,10 @@
*/
import { createReduxStore, register } from '@wordpress/data';
import { controls } from '@wordpress/data-controls';
-import { Reducer, AnyAction } from 'redux';
/**
* Internal dependencies
*/
+import type { AnyAction } from '../crud/types';
import { STORE_NAME } from './constants';
import * as selectors from './selectors';
import * as actions from './actions';
@@ -16,7 +16,10 @@ export * from './types';
export type { State };
export const store = createReduxStore( STORE_NAME, {
- reducer: reducer as Reducer< State, AnyAction >,
+ reducer: reducer as (
+ state: State | undefined,
+ action: AnyAction
+ ) => State,
actions,
controls,
selectors,
diff --git a/packages/js/data/src/import/reducer.ts b/packages/js/data/src/import/reducer.ts
index bee15f53b5f..98e18b44aaa 100644
--- a/packages/js/data/src/import/reducer.ts
+++ b/packages/js/data/src/import/reducer.ts
@@ -3,7 +3,6 @@
*/
import moment from 'moment';
import { getShortDateFormat } from '@woocommerce/date';
-import type { Reducer } from 'redux';
/**
* Internal dependencies
@@ -12,8 +11,8 @@ import TYPES from './action-types';
import { ImportState } from './types';
import { Action } from './actions';
-const reducer: Reducer< ImportState, Action > = (
- state = {
+const reducer = (
+ state: ImportState = {
activeImport: false,
importStatus: {},
importTotals: {},
@@ -25,8 +24,8 @@ const reducer: Reducer< ImportState, Action > = (
},
skipPrevious: true,
},
- action
-) => {
+ action: Action
+): ImportState => {
switch ( action.type ) {
case TYPES.SET_IMPORT_STARTED:
const { activeImport } = action;
diff --git a/packages/js/data/src/items/reducer.ts b/packages/js/data/src/items/reducer.ts
index f6c5fca796b..34dedd698a7 100644
--- a/packages/js/data/src/items/reducer.ts
+++ b/packages/js/data/src/items/reducer.ts
@@ -1,9 +1,3 @@
-/**
- * External dependencies
- */
-
-import type { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -19,10 +13,10 @@ const initialState: ItemsState = {
data: {},
};
-const reducer: Reducer< ItemsState, Action > = (
- state = initialState,
- action
-) => {
+const reducer = (
+ state: ItemsState = initialState,
+ action: Action
+): ItemsState => {
switch ( action.type ) {
case TYPES.SET_ITEM: {
const itemData = state.data[ action.itemType ] || {};
diff --git a/packages/js/data/src/navigation/reducer.ts b/packages/js/data/src/navigation/reducer.ts
index 0b051f35591..2379da6cd49 100644
--- a/packages/js/data/src/navigation/reducer.ts
+++ b/packages/js/data/src/navigation/reducer.ts
@@ -1,8 +1,3 @@
-/**
- * External dependencies
- */
-import type { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -10,16 +5,16 @@ import TYPES from './action-types';
import { Action } from './actions';
import { NavigationState } from './types';
-const reducer: Reducer< NavigationState, Action > = (
- state = {
+const reducer = (
+ state: NavigationState = {
error: null,
menuItems: [],
favorites: [],
requesting: {},
persistedQuery: {},
},
- action
-) => {
+ action: Action
+): NavigationState => {
switch ( action.type ) {
case TYPES.SET_MENU_ITEMS:
state = {
diff --git a/packages/js/data/src/notes/index.ts b/packages/js/data/src/notes/index.ts
index 01eb0307d88..052f5a84f07 100644
--- a/packages/js/data/src/notes/index.ts
+++ b/packages/js/data/src/notes/index.ts
@@ -2,12 +2,12 @@
* External dependencies
*/
import { createReduxStore, register } from '@wordpress/data';
-import { Reducer, AnyAction } from 'redux';
import { controls } from '@wordpress/data-controls';
/**
* Internal dependencies
*/
+import type { AnyAction } from '../crud/types';
import { STORE_NAME } from './constants';
import * as selectors from './selectors';
import * as actions from './actions';
@@ -18,7 +18,10 @@ export * from './types';
export type { State };
export const store = createReduxStore( STORE_NAME, {
- reducer: reducer as Reducer< State, AnyAction >,
+ reducer: reducer as (
+ state: State | undefined,
+ action: AnyAction
+ ) => State,
actions,
controls,
selectors,
diff --git a/packages/js/data/src/notes/reducer.ts b/packages/js/data/src/notes/reducer.ts
index 4ce3b442ce1..dc765995d08 100644
--- a/packages/js/data/src/notes/reducer.ts
+++ b/packages/js/data/src/notes/reducer.ts
@@ -1,9 +1,3 @@
-/**
- * External dependencies
- */
-
-import type { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -11,15 +5,15 @@ import TYPES from './action-types';
import { Action } from './actions';
import { NoteState, Note } from './types';
-const reducer: Reducer< NoteState, Action > = (
- state = {
+const reducer = (
+ state: NoteState = {
errors: {},
noteQueries: {},
notes: {},
requesting: {},
},
- action
-) => {
+ action: Action
+): NoteState => {
switch ( action.type ) {
case TYPES.SET_NOTES:
state = {
diff --git a/packages/js/data/src/onboarding/reducer.ts b/packages/js/data/src/onboarding/reducer.ts
index bae64ab33e6..77e0121f870 100644
--- a/packages/js/data/src/onboarding/reducer.ts
+++ b/packages/js/data/src/onboarding/reducer.ts
@@ -1,9 +1,3 @@
-/**
- * External dependencies
- */
-
-import type { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -79,10 +73,10 @@ const getUpdatedTaskLists = (
);
};
-const reducer: Reducer< OnboardingState, Action > = (
- state = defaultState,
- action
-) => {
+const reducer = (
+ state: OnboardingState = defaultState,
+ action: Action
+): OnboardingState => {
switch ( action.type ) {
case TYPES.SET_PROFILE_ITEMS:
return {
diff --git a/packages/js/data/src/options/reducer.ts b/packages/js/data/src/options/reducer.ts
index 734b1aad76d..5df834a4b7d 100644
--- a/packages/js/data/src/options/reducer.ts
+++ b/packages/js/data/src/options/reducer.ts
@@ -1,9 +1,3 @@
-/**
- * External dependencies
- */
-
-import type { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -11,10 +5,10 @@ import TYPES from './action-types';
import { Action } from './actions';
import { OptionsState } from './types';
-const optionsReducer: Reducer< OptionsState, Action > = (
- state = { isUpdating: false, requestingErrors: {} },
- action
-) => {
+const optionsReducer = (
+ state: OptionsState = { isUpdating: false, requestingErrors: {} },
+ action: Action
+): OptionsState => {
switch ( action.type ) {
case TYPES.RECEIVE_OPTIONS:
state = {
diff --git a/packages/js/data/src/orders/reducer.ts b/packages/js/data/src/orders/reducer.ts
index e788e439798..f4a079b307e 100644
--- a/packages/js/data/src/orders/reducer.ts
+++ b/packages/js/data/src/orders/reducer.ts
@@ -1,8 +1,3 @@
-/**
- * External dependencies
- */
-import { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -23,15 +18,15 @@ export type OrdersState = {
data: Record< number, PartialOrder >;
};
-const reducer: Reducer< OrdersState, Actions > = (
- state = {
+const reducer = (
+ state: OrdersState = {
orders: {},
ordersCount: {},
errors: {},
data: {},
},
- payload
-) => {
+ payload: Actions
+): OrdersState => {
if ( payload && 'type' in payload ) {
switch ( payload.type ) {
case TYPES.GET_ORDER_SUCCESS:
diff --git a/packages/js/data/src/plugins/reducer.ts b/packages/js/data/src/plugins/reducer.ts
index 8be0c9a7157..ca881819401 100644
--- a/packages/js/data/src/plugins/reducer.ts
+++ b/packages/js/data/src/plugins/reducer.ts
@@ -2,7 +2,6 @@
* External dependencies
*/
import { concat } from 'lodash';
-import { Reducer } from 'redux';
/**
* Internal dependencies
@@ -11,8 +10,8 @@ import { ACTION_TYPES as TYPES } from './action-types';
import { Actions } from './actions';
import { PluginsState } from './types';
-const reducer: Reducer< PluginsState, Actions > = (
- state = {
+const reducer = (
+ state: PluginsState = {
active: [],
installed: [],
requesting: {},
@@ -20,8 +19,8 @@ const reducer: Reducer< PluginsState, Actions > = (
jetpackConnectUrls: {},
recommended: {},
},
- payload
-) => {
+ payload: Actions
+): PluginsState => {
if ( payload && 'type' in payload ) {
switch ( payload.type ) {
case TYPES.UPDATE_ACTIVE_PLUGINS:
diff --git a/packages/js/data/src/product-form/reducer.ts b/packages/js/data/src/product-form/reducer.ts
index 300d538fd46..5346e4c558b 100644
--- a/packages/js/data/src/product-form/reducer.ts
+++ b/packages/js/data/src/product-form/reducer.ts
@@ -1,9 +1,3 @@
-/**
- * External dependencies
- */
-
-import type { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -11,16 +5,16 @@ import TYPES from './action-types';
import { Action } from './actions';
import { ProductFormState } from './types';
-const reducer: Reducer< ProductFormState, Action > = (
- state = {
+const reducer = (
+ state: ProductFormState = {
errors: {},
fields: [],
sections: [],
subsections: [],
tabs: [],
},
- action
-) => {
+ action: Action
+): ProductFormState => {
switch ( action.type ) {
case TYPES.GET_FIELDS_SUCCESS:
state = {
diff --git a/packages/js/data/src/product-variations/index.ts b/packages/js/data/src/product-variations/index.ts
index 88ede187125..ebd072230ed 100644
--- a/packages/js/data/src/product-variations/index.ts
+++ b/packages/js/data/src/product-variations/index.ts
@@ -1,11 +1,7 @@
-/**
- * External dependencies
- */
-import { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
+import type { AnyAction } from '../crud/types';
import { STORE_NAME, WC_PRODUCT_VARIATIONS_NAMESPACE } from './constants';
import { createCrudDataStore } from '../crud';
import * as actions from './actions';
@@ -23,7 +19,10 @@ export const store = createCrudDataStore<
pluralResourceName: 'ProductVariations',
namespace: WC_PRODUCT_VARIATIONS_NAMESPACE,
storeConfig: {
- reducer: reducer as Reducer< ResourceState >,
+ reducer: reducer as (
+ state: ResourceState | undefined,
+ action: AnyAction
+ ) => ResourceState,
actions: actions as ProductVariationActions,
selectors: selectors as ProductVariationSelectors,
},
diff --git a/packages/js/data/src/product-variations/reducer.ts b/packages/js/data/src/product-variations/reducer.ts
index 7cf0433ee7a..67d2536b136 100644
--- a/packages/js/data/src/product-variations/reducer.ts
+++ b/packages/js/data/src/product-variations/reducer.ts
@@ -1,8 +1,3 @@
-/**
- * External dependencies
- */
-import { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -12,16 +7,16 @@ import { ResourceState } from '../crud/reducer';
import { getRequestIdentifier } from '../crud/utils';
import CRUD_ACTIONS from './crud-actions';
-const reducer: Reducer< ResourceState, Actions > = (
- state = {
+const reducer = (
+ state: ResourceState = {
items: {},
data: {},
itemsCount: {},
errors: {},
requesting: {},
},
- payload
-) => {
+ payload: Actions
+): ResourceState => {
if ( payload && 'type' in payload ) {
switch ( payload.type ) {
case TYPES.GENERATE_VARIATIONS_REQUEST:
diff --git a/packages/js/data/src/products/reducer.ts b/packages/js/data/src/products/reducer.ts
index 63584e23b08..8cedc0db431 100644
--- a/packages/js/data/src/products/reducer.ts
+++ b/packages/js/data/src/products/reducer.ts
@@ -1,8 +1,3 @@
-/**
- * External dependencies
- */
-import { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -42,8 +37,8 @@ export type ProductState = {
};
};
-const reducer: Reducer< ProductState, Actions > = (
- state = {
+const reducer = (
+ state: ProductState = {
products: {},
productsCount: {},
errors: {},
@@ -51,8 +46,8 @@ const reducer: Reducer< ProductState, Actions > = (
pending: {},
suggestedProducts: {},
},
- payload
-) => {
+ payload: Actions
+): ProductState => {
if ( payload && 'type' in payload ) {
switch ( payload.type ) {
case TYPES.CREATE_PRODUCT_START:
diff --git a/packages/js/data/src/reports/reducer.ts b/packages/js/data/src/reports/reducer.ts
index 1614c794d50..1c5684a8b8e 100644
--- a/packages/js/data/src/reports/reducer.ts
+++ b/packages/js/data/src/reports/reducer.ts
@@ -1,8 +1,3 @@
-/**
- * External dependencies
- */
-import type { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -16,10 +11,10 @@ const initialState: ReportState = {
statErrors: {},
stats: {},
};
-const reducer: Reducer< ReportState, Action > = (
- state = initialState,
- action
-) => {
+const reducer = (
+ state: ReportState = initialState,
+ action: Action
+): ReportState => {
switch ( action.type ) {
case TYPES.SET_REPORT_ITEMS:
return {
diff --git a/packages/js/data/src/reviews/reducer.ts b/packages/js/data/src/reviews/reducer.ts
index d4c3c9fed97..f5767449f70 100644
--- a/packages/js/data/src/reviews/reducer.ts
+++ b/packages/js/data/src/reviews/reducer.ts
@@ -1,8 +1,3 @@
-/**
- * External dependencies
- */
-
-import type { Reducer } from 'redux';
/**
* Internal dependencies
*/
@@ -15,10 +10,10 @@ const initialState: ReviewsState = {
errors: {},
data: {},
};
-const reducer: Reducer< ReviewsState, Action > = (
- state = initialState,
- action
-) => {
+const reducer = (
+ state: ReviewsState = initialState,
+ action: Action
+): ReviewsState => {
switch ( action.type ) {
case TYPES.UPDATE_REVIEWS:
const ids: Array< number > = [];
diff --git a/packages/js/data/src/settings/index.ts b/packages/js/data/src/settings/index.ts
index 8e30d7c7637..fedf9f4706d 100644
--- a/packages/js/data/src/settings/index.ts
+++ b/packages/js/data/src/settings/index.ts
@@ -3,11 +3,11 @@
*/
import { createReduxStore, register } from '@wordpress/data';
import { controls } from '@wordpress/data-controls';
-import type { Reducer } from 'redux';
/**
* Internal dependencies
*/
+import type { AnyAction } from '../crud/types';
import { STORE_NAME } from './constants';
import * as selectors from './selectors';
import * as actions from './actions';
@@ -19,7 +19,10 @@ export * from './types';
export type { State };
export const store = createReduxStore( STORE_NAME, {
- reducer: reducer as Reducer< SettingsState >,
+ reducer: reducer as (
+ state: SettingsState | undefined,
+ action: AnyAction
+ ) => SettingsState,
actions,
controls,
selectors,
diff --git a/packages/js/data/src/settings/reducer.ts b/packages/js/data/src/settings/reducer.ts
index 02c05706300..0dae5578e72 100644
--- a/packages/js/data/src/settings/reducer.ts
+++ b/packages/js/data/src/settings/reducer.ts
@@ -2,7 +2,6 @@
* External dependencies
*/
import { union } from 'lodash';
-import { Reducer } from 'redux';
/**
* Internal dependencies
@@ -38,7 +37,10 @@ const updateGroupDataInNewState = (
return newState;
};
-const reducer: Reducer< SettingsState, Actions > = ( state = {}, action ) => {
+const reducer = (
+ state: SettingsState = {},
+ action: Actions
+): SettingsState => {
const newState = {};
switch ( action.type ) {
case TYPES.SET_IS_REQUESTING:
diff --git a/packages/js/data/src/shipping-methods/reducer.ts b/packages/js/data/src/shipping-methods/reducer.ts
index fd3d10ea3d7..995fb69cfbf 100644
--- a/packages/js/data/src/shipping-methods/reducer.ts
+++ b/packages/js/data/src/shipping-methods/reducer.ts
@@ -1,8 +1,3 @@
-/**
- * External dependencies
- */
-import { Reducer } from 'redux';
-
/**
* Internal dependencies
*/
@@ -16,14 +11,14 @@ export type ShippingMethodsState = {
errors: Record< string, unknown >;
};
-const reducer: Reducer< ShippingMethodsState, Actions > = (
- state = {
+const reducer = (
+ state: ShippingMethodsState = {
shippingMethods: [],
isUpdating: false,
errors: {},
},
- payload
-) => {
+ payload: Actions
+): ShippingMethodsState => {
if ( payload && 'type' in payload ) {
switch ( payload.type ) {
case ACTION_TYPES.GET_SHIPPING_METHODS_REQUEST:
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a5e8bcf23c1..479346497f4 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1131,9 +1131,6 @@ importers:
react-dom:
specifier: 18.3.x
version: 18.3.1(react@18.3.1)
- redux:
- specifier: ^4.2.1
- version: 4.2.1
rimraf:
specifier: catalog:tooling
version: 5.0.5