Skip to content

Instantly share code, notes, and snippets.

@nmn
Created July 9, 2016 04:50
Show Gist options
  • Save nmn/f125bf5575e0acabc79c48107d91aefb to your computer and use it in GitHub Desktop.
Save nmn/f125bf5575e0acabc79c48107d91aefb to your computer and use it in GitHub Desktop.
MagicFlowType 3: Type to convert nullable to non-nullable types
/* @flow */
type _NonNull<T, N: ?T> = T
type $NonNull<N> = _NonNull<*, N>
type Num = $NonNull<?number>
;(45: Num)
// $ExpectError
;(undefined: Num)
// $ExpectError
;(null: Num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment