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

Plugins dispatch is never inferred #50

Open
tpluscode opened this issue Nov 23, 2022 · 0 comments
Open

Plugins dispatch is never inferred #50

tpluscode opened this issue Nov 23, 2022 · 0 comments

Comments

@tpluscode
Copy link

This has been haunting me for some time. When I add a plugin with model to a store, rdx does recognize its reducers and they are not showing up on the store's dispatch

I finally found the issue, which is between the definition of Plugin and how the model is then extracted

export interface Plugin<M extends Model = Model> {
  model?: M
}

type KeysOfPluginsWithModels<P extends Plugins> = {
  [K in keyof P]: undefined extends ExtractPluginModel<P[K]> ? never : K
}[keyof P]

Because Plugin['model'] is optional, it will always hit the undefined extends ExtractPluginModel<P[K]> condition, regardless of it actually being present on the given plugin.

I have been unable to figure out what is happening. Maybe this is related to another issue I found, and also experienced with TS 4.3+. When installed in the rdx repo, this error shows in effects-config.ts

TS7022: 'testModel' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

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

No branches or pull requests

1 participant