Skip to content

[3.0] Remove Action generic argument from configureStore#5345

Open
veksa wants to merge 1 commit into
reduxjs:masterfrom
veksa:fix/remove-configurestore-action-generic
Open

[3.0] Remove Action generic argument from configureStore#5345
veksa wants to merge 1 commit into
reduxjs:masterfrom
veksa:fix/remove-configurestore-action-generic

Conversation

@veksa

@veksa veksa commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Closes #5317.

Drops the Action generic (A extends Action = UnknownAction) from configureStore, ConfigureStoreOptions and EnhancedStore.

Anything other than UnknownAction for the store's action type has been discouraged for ages, but having the generic there kept inviting the opposite. People assume that if an action type can be passed in, it should flow through dispatch and into middleware — then get surprised when it doesn't (reduxjs/redux#4887 is a good example). Removing the argument makes the contract obvious: the store always dispatches UnknownAction, and you narrow with type guards where needed.

What changed

The three types now have one fewer generic — configureStore<S, M, E, P> and EnhancedStore<S, E> — and the store is always Store<S, UnknownAction, …>.

One thing worth calling out: the reducer option uses any in the action slot (Reducer<S, any, P> | ReducersMapObject<S, any, P>) rather than UnknownAction. UnknownAction there rejects perfectly good reducers typed for a specific action — including anything from combineReducers, since that keeps a concrete action union — because of parameter contravariance under strictFunctionTypes. any keeps accepting whatever reducer gets passed while the store type itself stays UnknownAction.

The API docs are updated to match, and the middleware/enhancers descriptions are fixed too — they still claimed an array could be passed, which hasn't been true since 2.x (a maintainer pointed this out in redux#4887 as well).

Breaking change

Aimed at 3.0. Nothing changes if the action type was never written out explicitly — the default was already UnknownAction. It only bites something like configureStore<State, MyAction>(…) or an explicit EnhancedStore<State, MyAction, …> annotation, since dropping the parameter shifts the remaining generics along. The fix is to remove the action type argument.

Testing

Type checks and the configureStore typecheck suite pass, and the reworked type test confirms a specifically-typed reducer is still accepted and just produces an UnknownAction store.

@codesandbox

codesandbox Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@netlify

netlify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit be234c4
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/6a5e1d6eebc53700081e3756
😎 Deploy Preview https://deploy-preview-5345--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@EskiMojo14 EskiMojo14 added this to the 3.0 milestone Jul 20, 2026
@EskiMojo14

Copy link
Copy Markdown
Collaborator

One thing worth calling out: the reducer option uses any in the action slot (Reducer<S, any, P> | ReducersMapObject<S, any, P>) rather than UnknownAction. UnknownAction there rejects perfectly good reducers typed for a specific action — including anything from combineReducers, since that keeps a concrete action union — because of parameter contravariance under strictFunctionTypes. any keeps accepting whatever reducer gets passed while the store type itself stays UnknownAction.

Seems like the rejection would be correct? Reducers should not be typed to accept specific actions, that's the point of this change. Reducers can be called with any action (and will be), and should return state unchanged if the action is unrecognised.

@veksa

veksa commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Seems like the rejection would be correct? Reducers should not be typed to accept specific actions, that's the point of this change. Reducers can be called with any action (and will be), and should return state unchanged if the action is unrecognised.

Good point - you're right, I'll switch it to UnknownAction.

@veksa
veksa force-pushed the fix/remove-configurestore-action-generic branch from 54f5803 to be234c4 Compare July 20, 2026 13:06
@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@reduxjs/rtk-codemods

npm i https://pkg.pr.new/@reduxjs/rtk-codemods@be234c4 -D
yarn add https://pkg.pr.new/@reduxjs/rtk-codemods@be234c4.tgz -D
pnpm add https://pkg.pr.new/@reduxjs/rtk-codemods@be234c4.tgz -D
bun add https://pkg.pr.new/@reduxjs/rtk-codemods@be234c4.tgz -D

@rtk-query/codegen-openapi

npm i https://pkg.pr.new/@rtk-query/codegen-openapi@be234c4 -D
yarn add https://pkg.pr.new/@rtk-query/codegen-openapi@be234c4.tgz -D
pnpm add https://pkg.pr.new/@rtk-query/codegen-openapi@be234c4.tgz -D
bun add https://pkg.pr.new/@rtk-query/codegen-openapi@be234c4.tgz -D

@rtk-query/graphql-request-base-query

npm i https://pkg.pr.new/@rtk-query/graphql-request-base-query@be234c4 -D
yarn add https://pkg.pr.new/@rtk-query/graphql-request-base-query@be234c4.tgz -D
pnpm add https://pkg.pr.new/@rtk-query/graphql-request-base-query@be234c4.tgz -D
bun add https://pkg.pr.new/@rtk-query/graphql-request-base-query@be234c4.tgz -D

@reduxjs/toolkit

npm i https://pkg.pr.new/@reduxjs/toolkit@be234c4 -D
yarn add https://pkg.pr.new/@reduxjs/toolkit@be234c4.tgz -D
pnpm add https://pkg.pr.new/@reduxjs/toolkit@be234c4.tgz -D
bun add https://pkg.pr.new/@reduxjs/toolkit@be234c4.tgz -D

commit: be234c4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[3.0] remove Action generic argument from configureStore

2 participants