File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,23 @@ class Thing {
81
81
}
82
82
```
83
83
84
+ Using included [ type guards] ( https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates ) .
85
+
86
+ ``` ts
87
+ import { RemoteData } from ' @abraham/remotedata' ;
88
+ import { Status } from ' twitter-d' ;
89
+ import { getState } from ' ./state' ;
90
+
91
+ // Define what the RemoteData Failure and Success types will be.
92
+ type State = RemoteData <number , Status >;
93
+
94
+ const state: State = getState ();
95
+ if (isSuccess (state )) {
96
+ // state is known to be of type Success<Status>
97
+ console .log (state .data .full_text );
98
+ }
99
+ ```
100
+
84
101
# References
85
102
86
103
- [ How Elm Slays a UI Antipattern] ( http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html )
You can’t perform that action at this time.
0 commit comments