flowjs / flow.js

A JavaScript library providing multiple simultaneous, stable, fault-tolerant and resumable/restartable file uploads via the HTML5 File API.
Other
2.97k stars 347 forks source link

Refinement lost inside map #251

Closed maxsalven closed 6 years ago

maxsalven commented 6 years ago

Type refinements seem to be lost inside an Array.map call:

/* @flow */

type Action =
  | {
      flag: true,
      other: true,
    }
  | {
      flag: false,
    };

function reducer(action: Action): any {
  switch (action.flag) {
    case true:
      // return action.other; // This is ok
      return [1].map(item => action.other); // This is not
    default:
      return;
  }
}

https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoVAXAngBwKZgCCAxhgJZwB2YAvKmGAD5gDe9DHsAhgOYBcYDACcArngA07DmDgYAFniEDhYydIC+7Zm2kNu-MFC4wAzhKlh1AbnRQRlUhWpC8AExHFFACi6OqAknIqAEoBLkosVnYTBDIMYjkwHz9KADp9YKjpYi4zQVE8PgsGYGAwFwwRIWpfILTZBSErMFKwABU5MhMwLpkAa2LyvErqsABtAEYAXVSAWy4cLzi8WdoAPjBap1SGxWDm1o7e3spZC1c8IxEYDCLdIZHKGwZNTSA