Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. // @flow
  2.  
  3. interface ExtraField {
  4. note: string;
  5. }
  6.  
  7. type Success = ExtraField & { success: true, value: boolean };
  8. type Failed = { success: false, error: string };
  9.  
  10. type Response = Success | Failed;
  11.  
  12. function handleResponse(response: Response) {
  13. if (response.success) {
  14. var value: boolean = response.value;
  15. } else {
  16. var error: string = response.error; // Error!
  17. }
  18. }
  19.  
  20. Cannot get `response.error` because: Either property `error` is missing in `ExtraField` [1]. Or property `error` is missing in object type [2]
  21.  
  22. type ExtraField = {
  23. note: string
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement