Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS Error] Argument of type 'StoreEnhancer | ....' is not assignable to parameter of type 'StoreEnhancer<{}, {}> | undefined'. #12

Open
Maker-Mark opened this issue Oct 3, 2024 · 4 comments
Labels
bug Something isn't working waiting for response Waiting for a response to be able to deal with the issue or PR

Comments

@Maker-Mark
Copy link

Following the usage guide for legacy redux with middleware + ts:

import { createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "redux-devtools-expo-dev-plugin";

const store = createStore(
  reducer,
  /* preloadedState, */ composeWithDevTools(
    applyMiddleware(...middleware),
    // other store enhancers if any
  ),
);

Is giving the following TS error signifying the signature is mismatched.

Argument of type 'StoreEnhancer | ((...funcs: StoreEnhancer[]) => (...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>) | ((...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>)' is not assignable to parameter of type 'StoreEnhancer<{}, {}> | undefined'.
      Type '(...funcs: StoreEnhancer[]) => (...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>' is not assignable to type 'StoreEnhancer<{}, {}>'

The signature of @redux-devtools/extension's composeWithDevToolsDevelopmentOnly works as expected and using a similar definition as theirs fixes the TS issue.
Is this something wrong on my end or is there a legitimate ts mismatch for this?

diff --git a/node_modules/redux-devtools-expo-dev-plugin/build/devtools.d.ts b/node_modules/redux-devtools-expo-dev-plugin/build/devtools.d.ts
index 7a35a88..e658fd4 100644
--- a/node_modules/redux-devtools-expo-dev-plugin/build/devtools.d.ts
+++ b/node_modules/redux-devtools-expo-dev-plugin/build/devtools.d.ts
@@ -47,5 +47,5 @@ interface Options<S, A extends Action<string>> {
 }
 declare const _default: <S, A extends Action<string>>(options?: Options<S, A>) => StoreEnhancer;
 export default _default;
-export declare function composeWithDevTools(...funcs: [Options<unknown, Action<string>>] | StoreEnhancer[]): StoreEnhancer | ((...funcs: StoreEnhancer[]) => (...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>) | ((...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>);
+export declare function composeWithDevTools(...funcs: StoreEnhancer[] | [Options<unknown, Action<string>>]): StoreEnhancer;
 //# sourceMappingURL=devtools.d.ts.map
\ No newline at end of file
@Maker-Mark Maker-Mark changed the title [TS Error] Argument of type 'StoreEnhancer | ((...funcs: StoreEnhancer[]) => (...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>) | ((...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>)' is not assignable to parameter of type 'StoreEnhancer<{}, {}> | undefined'. Type '(...funcs: StoreEnhancer[]) => (...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>' is not assignable to type 'StoreEnhancer<{}, {}>' [TS Error] Argument of type 'StoreEnhancer | ((...funcs: StoreEnhancer[]) => (...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>) | ((...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>)' is not assignable to parameter of type 'StoreEnhancer<{}, {}> | undefined'. Oct 3, 2024
@Maker-Mark Maker-Mark changed the title [TS Error] Argument of type 'StoreEnhancer | ((...funcs: StoreEnhancer[]) => (...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>) | ((...args: unknown[]) => StoreEnhancerStoreCreator<{}, {}>)' is not assignable to parameter of type 'StoreEnhancer<{}, {}> | undefined'. [TS Error] Argument of type 'StoreEnhancer | ....' is not assignable to parameter of type 'StoreEnhancer<{}, {}> | undefined'. Oct 3, 2024
@matt-oakes
Copy link
Owner

Is it just the typing that is the issue? If you add a /// @tsignore comment does everything work as expected?

@matt-oakes matt-oakes added bug Something isn't working waiting for response Waiting for a response to be able to deal with the issue or PR labels Oct 4, 2024
@Maker-Mark
Copy link
Author

@matt-oakes Yes this is just a TS issue! All works as expected with/without @tsignore, and the ts issue goes away if you apply the patch.
Does that make sense?

@matt-oakes
Copy link
Owner

It does. I'm unsure if changing the library to match your patch would cause issues for other people with different setups.

For now, keep using the patch and I will investigate this next time I work on this project. Note that this might be a while as I'm currently working on client apps full time.

If anyone else can investigate if this patch causes and issues, then leave a comment or open a PR with your findings and we can get it merged.

In the meantime, thanks for reporting this issue and providing a workaround for people!

@Maker-Mark
Copy link
Author

@matt-oakes Of course, no problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for response Waiting for a response to be able to deal with the issue or PR
Projects
None yet
Development

No branches or pull requests

2 participants