Skip to content

Commit

Permalink
Merge pull request #4691 from renchap/patch-1
Browse files Browse the repository at this point in the history
Add a note to ignore `@typescript-eslint/ban-types` rule when typing middlewares
  • Loading branch information
EskiMojo14 committed Mar 29, 2024
2 parents 9e277ea + bf9193e commit 991dad0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/usage/UsageWithTypescript.md
Expand Up @@ -280,6 +280,12 @@ export const exampleMiddleware: Middleware<
}
```

:::caution

If you are using `typescript-eslint`, the `@typescript-eslint/ban-types` rule might report an error if you use `{}` for the dispatch value. The recommended changes it makes are incorrect and will break your Redux store types, you should disable the rule for this line and keep using `{}`.

:::

The dispatch generic should likely only be needed if you are dispatching additional thunks within the middleware.

In cases where `type RootState = ReturnType<typeof store.getState>` is used, a [circular type reference between the middleware and store definitions](https://github.com/reduxjs/redux/issues/4267) can be avoided by switching the type definition of `RootState` to:
Expand Down

0 comments on commit 991dad0

Please sign in to comment.