Last active
September 24, 2017 16:21
-
-
Save benadamstyles/ffb7c4339000c2f057905ffd80af9fa5 to your computer and use it in GitHub Desktop.
Flow Utility Type Functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Below are some useful Flow utility type functions, some I've written and some I've found on the web. | |
// All contributions welcome! | |
// Extracting a data type from a maybe type, e.g. getting `string` from `?string` | |
type _ExtractFromMaybe<T, M: ?T> = T | |
export type ExtractFromMaybe<M> = _ExtractFromMaybe<*, M> | |
// FROM https://hackernoon.com/redux-flow-type-getting-the-maximum-benefit-from-the-fewest-key-strokes-5c006c54ec87 | |
// Extracting the type of a function's return value | |
type _ExtractReturn<R, F: (...args: any[]) => R> = R | |
export type ExtractReturn<F> = _ExtractReturn<*, F> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment