File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,31 @@ const store = createStore(
14
14
```
15
15
Note that you many need to set ` no-any ` to false in your ` tslint.json ` file.
16
16
17
+ Alternatively you can use typeguard in order to avoid
18
+ casting to any.
19
+
20
+ ``` typescript
21
+ import { createStore , StoreEnhancer } from " redux" ;
22
+
23
+ // ...
24
+
25
+ type WindowWithDevTools = Window & {
26
+ __REDUX_DEVTOOLS_EXTENSION__: () => StoreEnhancer <unknown , {}>
27
+ }
28
+
29
+ const isReduxDevtoolsExtenstionExist =
30
+ (arg : Window | WindowWithDevTools ):
31
+ arg is WindowWithDevTools => {
32
+ return ' __REDUX_DEVTOOLS_EXTENSION__' in arg ;
33
+ }
34
+
35
+ // ...
36
+
37
+ const store = createStore (rootReducer , initialState ,
38
+ isReduxDevtoolsExtenstionExist (window ) ?
39
+ window .__REDUX_DEVTOOLS_EXTENSION__ () : undefined )
40
+ ```
41
+
17
42
### Export from browser console or from application
18
43
19
44
``` js
You can’t perform that action at this time.
0 commit comments