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
@@ -7,7 +7,7 @@ _"This guide is a **living compendium** documenting the most important patterns
7
7
8
8
:tada:_Now updated to be compatible with **TypeScript v3.1.6**_:tada:
9
9
10
-
:computer:_Reference implementation of Todo-App with `typesafe-actions`: https://codesandbox.io/s/github/piotrwitek/typesafe-actions-todo-app_:computer:
10
+
:computer:_Reference implementation of Todo-App with `typesafe-actions`: https://codesandbox.io/s/github/piotrwitek/typesafe-actions/tree/master/codesandbox_:computer:
11
11
12
12
### Goals
13
13
- Complete type safety (with [`--strict`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) flag) without losing type information downstream through all the layers of our application (e.g. no type assertions or hacking with `any` type)
@@ -59,9 +59,10 @@ Issues can be funded by anyone and the money will be transparently distributed t
59
59
-[Testing reducer](#testing-reducer)
60
60
-[Async Flow with `redux-observable`](#async-flow-with-redux-observable)
61
61
-[Typing Epics](#typing-epics)
62
-
-[Testing Epics](#testing-epics) 🌟 __NEW__
63
-
-[Selectors](#selectors)
64
-
-[Typing connect](#typing-connect)
62
+
-[Testing Epics](#testing-epics)
63
+
-[Async Flow with `redux-thunk`](#async-flow-with-redux-thunk) 🌟 __NEW__
64
+
-[Selectors with `reselect`](#selectors-with-reselect)
65
+
-[Connect with `react-redux`](#connect-with-react-redux) 🌟 __NEW__
> We'll be using a battle-tested library [](https://www.npmjs.com/package/typesafe-actions)
1046
-
that automates and simplify maintenace of **type annotations in Redux Architectures** [`typesafe-actions`](https://github.com/piotrwitek/typesafe-actions#typesafe-actions)
1081
+
that'll help retain complete type soundness and simplify maintenace of **types in Redux Architectures** [`typesafe-actions`](https://github.com/piotrwitek/typesafe-actions#typesafe-actions)
1047
1082
1048
-
### For more examples and in-depth tutorial you should check [The Mighty Tutorial](https://github.com/piotrwitek/typesafe-actions#behold-the-mighty-tutorial)!
1083
+
> You can find more real-world examples and in-depth tutorial in: [Typesafe-Actions - The Mighty Tutorial](https://github.com/piotrwitek/typesafe-actions#behold-the-mighty-tutorial)!
1049
1084
1050
1085
A solution below is using a simple factory function to automate the creation of type-safe action creators. The goal is to decrease maintenance effort and reduce code repetition of type annotations for actions and creators. The result is completely typesafe action-creators and their actions.
### For more examples and in-depth tutorial you should check [The Mighty Tutorial](https://github.com/piotrwitek/typesafe-actions#behold-the-mighty-tutorial)!
*__NOTE__: Below you'll find only a short explanation of concepts behind typing `connect`. For more advanced scenarios and common use-cases (`redux-thunk` and more...) please check [Redux Connected Components](#redux-connected-components) section.*
1428
+
*__NOTE__: Below you'll find only a short explanation of concepts behind typing `connect`. For more real-world examples please check [Redux Connected Components](#redux-connected-components) section.*
1398
1429
1399
1430
```tsx
1400
1431
importMyTypesfrom'MyTypes';
@@ -1425,10 +1456,34 @@ const dispatchToProps = {
1425
1456
// Notice ee don't need to pass any generic type parameters to neither connect nor map functions above
1426
1457
// because type inference will infer types from arguments annotations automatically
*__NOTE__ (for `redux-thunk`): When using thunk action creators you need to use `bindActionCreators`. Only this way you can get corrected dispatch props type signature like below.*
1464
+
1465
+
*__WARNING__: As of now (Apr 2019) `bindActionCreators` signature of the latest `redux-thunk` release will not work as below, you need to use updated type definitions that you can find in `/playground/typings/redux-thunk` folder and then add paths overload in your tsconfig like this: `"paths":{"redux-thunk":["typings/redux-thunk"]}`.*
0 commit comments