redux-devtools icon indicating copy to clipboard operation
redux-devtools copied to clipboard

fix(compose): generic types for devtools/extension

Open codeshake opened this issue 3 years ago • 5 comments

I wrote generic types for devtools/extension compose function because when passing async thunk-functions in store.dispatch typescript gives an error about type incompatibility.

Argument of type '(dispatch: asyncThunkDispatch) => Promise<void>' is not assignable to parameter of type 'appActionTypes | etc'. ts(2345)

codeshake avatar Apr 14 '22 15:04 codeshake

⚠️ No Changeset found

Latest commit: c7e84ff4dc915ed8bf231f7782c98dd6d5c9a8cf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Apr 14 '22 15:04 changeset-bot[bot]

Can you provide a TS playground that demonstrates the type error you're getting? A simple store setup with just Redux Thunk seems to be working for me and I'd just like to see what the use case is before accepting this PR.

Methuselah96 avatar Jul 05 '22 13:07 Methuselah96

https://codesandbox.io/s/react-playground-forked-2nhxnd?file=/index.ts Same problem with your code

codeshake avatar Jul 05 '22 21:07 codeshake

I'm trying out the new type here. The newComposeWithDevTools is typed the same way as in this PR, but I'm still getting a type error.

Additionally, my earlier point still stands that you can't have multiple enhancers that have different StoreExt generics and have it type-check properly. Here is an example of that not working properly after this PR.

Methuselah96 avatar Jul 06 '22 02:07 Methuselah96

Sorry for a long waiting.

https://codesandbox.io/s/react-playground-forked-w6ox9w

I wrote custom interface as in PR (compose.ts) and small redux-store. Watch in index.ts 5 line: here is async-dispatch without error. But if you switch in store.ts to your composeWithDevTools, you will get an error in index.

codeshake avatar Sep 16 '22 16:09 codeshake

Sorry for the delayed response.

I just released @redux-devtools/[email protected] with https://github.com/reduxjs/redux-devtools/pull/1323 that should fix this issue. Can you try it out when you get a chance to see if it resolves this issue for you?

Methuselah96 avatar Jan 09 '23 01:01 Methuselah96

I've tested the change on the CodeSandboxes provided in this thread and it seems to work correctly, so I'm closing this for now. Let me know if you still have issues.

Methuselah96 avatar Jan 11 '23 17:01 Methuselah96

Sorry for the delayed response.

I just released @redux-devtools/[email protected] with #1323 that should fix this issue. Can you try it out when you get a chance to see if it resolves this issue for you?

Yeah, it works!

codeshake avatar Jan 12 '23 21:01 codeshake