Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
narrow types: Make Narrow an opaque type.
In the preceding series of commits, we've taken all the places where our code used to depend on the details of our internal representation of narrows, and converted them so they use reasonable explicit interfaces provided by the `narrow` module. This commit recruits Flow to confirm for us that that job is complete. Because `Narrow` is now an opaque type, code outside this module now has to treat it as if it could mean anything: so it can't create a value of this type any more than it could of type `empty`, and can't consume one or break it down any more than it could a value of type `mixed`, the supertype of all types. Effectively this means that code outside `narrow` can only create a `Narrow` by invoking something inside the module; can then pass it around and store it however it pleases; but then can only inspect the information inside it by passing it back to something within the module, or to an operation like `===` or `JSON.stringify` that's completely generic so that it actually accepts type `mixed` as input. (The way this series was developed is that this commit came first, immediately after distinguishing the `ApiNarrow` type and making `Narrow` an alias of it in the first place. That produced a long list of Flow errors, which served as a to-do list to make the other changes in the series. Once complete, this commit was rebased to the end so that, as always, no commit in the series breaks our tests.)
- Loading branch information