Skip to content

docs(typescript): align AppThunk extra arg type with createAsyncThunk.withTypes#4873

Open
webdevelopersrinu wants to merge 1 commit into
reduxjs:masterfrom
webdevelopersrinu:fix/4602-appthunk-extra-arg-undefined
Open

docs(typescript): align AppThunk extra arg type with createAsyncThunk.withTypes#4873
webdevelopersrinu wants to merge 1 commit into
reduxjs:masterfrom
webdevelopersrinu:fix/4602-appthunk-extra-arg-undefined

Conversation

@webdevelopersrinu
Copy link
Copy Markdown

Summary

Aligns the AppThunk / ThunkAction examples in the docs and the
counter-ts example with how Redux Toolkit's createAsyncThunk.withTypes
actually types the thunk dispatcher.

Fixes #4602

The problem

The Redux docs recommend defining AppThunk with unknown as the
extra-argument generic. Meanwhile, RTK's createAsyncThunk.withTypes
defaults the extra argument to undefined when no extra is provided.
The result is a ThunkDispatch<RootState, unknown, ...> vs
ThunkDispatch<RootState, undefined, ...> mismatch, so dispatching a
typed RTK async thunk from inside a handwritten AppThunk raises a
TypeScript error.

The fix

Change the extra-argument generic from unknown to undefined in the
documented examples and in the counter-ts template, so the two
recommended patterns agree.

Files changed

  • docs/usage/UsageWithTypescript.mdAppThunk type, ThunkAction example, and surrounding prose
  • docs/tutorials/essentials/part-2-app-structure.mdAppThunk type
  • docs/tutorials/essentials/part-5-async-logic.mdAppThunk type
  • examples/counter-ts/src/app/store.tsAppThunk type

Total: 6 lines across 4 files.

Testing

Docs-only / example-only changes; no runtime behavior is affected.
Relying on CI to validate the Docusaurus build and the counter-ts
typecheck.

…Types

Change the 'extra argument' generic in AppThunk/ThunkAction examples from
`unknown` to `undefined` so that thunks dispatched via
`createAsyncThunk.withTypes` (which defaults to `undefined`) type-check
correctly when called inside a handwritten thunk.

Fixes reduxjs#4602
@codesandbox-ci
Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 20, 2026

Deploy Preview for redux-docs ready!

Name Link
🔨 Latest commit f1c6376
🔍 Latest deploy log https://app.netlify.com/projects/redux-docs/deploys/6a0d57671521630008942536
😎 Deploy Preview https://deploy-preview-4873--redux-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.

@aryaemami59 aryaemami59 added the Documentation Improvements or additions to documentation label May 20, 2026
@aryaemami59 aryaemami59 changed the title docs(typescript): align AppThunk extra arg type with createAsyncThunk.withTypes docs(typescript): align AppThunk extra arg type with createAsyncThunk.withTypes May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TS conflict between AppThunk and createAsyncThunk.withTypes

2 participants