You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**If you try to use `connect` or `bindActionCreators` explicitly and type your component callback props as `() =>void` this will raise compiler errorsbecause `bindActionCreators` typings will not map your action creator type correctly due to current TypeScript limitations.**
507
+
**If you try to use `connect` or `bindActionCreators` explicitly and want to type your component callback props as `() =>void` this will raise compiler errors. I happens because `bindActionCreators` typings will not map the return type of action creators to `void`, due to a current TypeScript limitations.**
506
508
507
-
A decent alternative I can recommend to use is a`() =>any` type, it will work just fine in all possible scenarios and should not cause any typing problems whatsoever. All the code examples in the Guide with `connect` are also using this pattern.
509
+
A decent alternative I can recommend is to use `() =>any` type, it will work just fine in all possible scenarios and should not cause any typing problems whatsoever. All the code examples in the Guide with `connect` are also using this pattern.
508
510
509
511
> If there is any progress or fix in regard to the above caveat I'll update the guide and make an announcement on my twitter/medium (There are a few existing proposals already).
510
512
511
-
> There is also a way to retain type soundness but it will involve an explicit wrapping with `dispatch` and is very tedious for the long run. See example below:
513
+
> There is alternative way to retain type soundness but it requires an explicit wrapping with `dispatch` and will be very tedious for the long run. See example below:
> Using Typesafe Action Creators helpers for Redux [`typesafe-actions`](https://github.com/piotrwitek/typesafe-actions)
642
644
643
645
A recommended approach is to use a simple functional helper to automate the creation of type-safe action creators. The advantage is that we can reduce a lot of code repetition and also minimize surface of errors by using type-checked API.
644
-
> There are more specialized functional helpers available that will help you to further reduce tedious boilerplate and type-annotations in common scenarios like reducers (`getType`) or epics (`isActionOf`). All that without losing type-safety! Please check very short [Tutorial](https://github.com/piotrwitek/typesafe-actions#tutorial)
646
+
> There are more specialized functional helpers available that will help you to further reduce tedious boilerplate and type-annotations in common scenarios like reducers (`getType`) or epics (`isActionOf`).
647
+
All that without losing type-safety! Please check this very short [Tutorial](https://github.com/piotrwitek/typesafe-actions#tutorial)
Copy file name to clipboardExpand all lines: docs/markdown/1_react.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -135,13 +135,13 @@ Adds error handling using componentDidCatch to any component
135
135
## Redux Connected Components
136
136
137
137
### Caveat with `bindActionCreators`
138
-
**If you try to use `connect` or `bindActionCreators` explicitly and type your component callback props as `() =>void` this will raise compiler errorsbecause `bindActionCreators` typings will not map your action creator type correctly due to current TypeScript limitations.**
138
+
**If you try to use `connect` or `bindActionCreators` explicitly and want to type your component callback props as `() =>void` this will raise compiler errors. I happens because `bindActionCreators` typings will not map the return type of action creators to `void`, due to a current TypeScript limitations.**
139
139
140
-
A decent alternative I can recommend to use is a`() =>any` type, it will work just fine in all possible scenarios and should not cause any typing problems whatsoever. All the code examples in the Guide with `connect` are also using this pattern.
140
+
A decent alternative I can recommend is to use `() =>any` type, it will work just fine in all possible scenarios and should not cause any typing problems whatsoever. All the code examples in the Guide with `connect` are also using this pattern.
141
141
142
142
> If there is any progress or fix in regard to the above caveat I'll update the guide and make an announcement on my twitter/medium (There are a few existing proposals already).
143
143
144
-
> There is also a way to retain type soundness but it will involve an explicit wrapping with `dispatch` and is very tedious for the long run. See example below:
144
+
> There is alternative way to retain type soundness but it requires an explicit wrapping with `dispatch` and will be very tedious for the long run. See example below:
Copy file name to clipboardExpand all lines: docs/markdown/2_redux.md
+5-6Lines changed: 5 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,8 @@
5
5
> Using Typesafe Action Creators helpers for Redux [`typesafe-actions`](https://github.com/piotrwitek/typesafe-actions)
6
6
7
7
A recommended approach is to use a simple functional helper to automate the creation of type-safe action creators. The advantage is that we can reduce a lot of code repetition and also minimize surface of errors by using type-checked API.
8
-
> There are more specialized functional helpers available that will help you to further reduce tedious boilerplate and type-annotations in common scenarios like reducers (`getType`) or epics (`isActionOf`). All that without losing type-safety! Please check very short [Tutorial](https://github.com/piotrwitek/typesafe-actions#tutorial)
8
+
> There are more specialized functional helpers available that will help you to further reduce tedious boilerplate and type-annotations in common scenarios like reducers (`getType`) or epics (`isActionOf`).
9
+
All that without losing type-safety! Please check this very short [Tutorial](https://github.com/piotrwitek/typesafe-actions#tutorial)
0 commit comments