github facebook/flow v0.246.0

4 days ago

Likely to cause new Flow errors:

  • Support for $ObjMap has been completely removed. This change means that:
    • $ObjMap will resolve to a user-defined $ObjMap global if it's available in your libdef. You can use type $ObjMap<O, F> = {[K in keyof O]: $Call<F, O[K]>} to get most of the same behavior, except that in the mapped type version O[K] will include void for optional props. Please note that this should be considered as a permanent shim, because we intend to eventually remove $Call.
    • flow codemod key-mirror command was removed, since this codemod tries to convert $ObjMap to $KeyMirror
    • deprecated-type-objmap lint was removed.
  • Component syntax components without ref prop will have void as the instance, so React.ElementRef<component> of such component will return void.

New Features:

  • Mapped types now support array and tuple types in the form of {[K in keyof <array or tuple type>: <mapped type>}.
    • With this support, we intend to deprecate $TupleMap in the next release and remove the support for $TupleMap eventually
  • You can now refine against variables and member expressions with a literal type, not just literal themselves.

Notable bug fixes:

  • Flow now only reports one error when two disjoint large enum-like unions are compared (example).

IDE:

  • Code actions on component syntax components will produce smaller targeted edits, rather than reprint the entire component.
  • Deprecated utility type like $Call are no longer suggested in autocomplete.
  • Flow will now provide a quick fix when the spread prop of a component with component syntax redefines some already defined props.

Library Definitions:

  • React.Ref is marked as deprecated. Use React.RefSetter instead for ref props, and React.RefObject for returns of useRef.
  • React.RefSetter now includes null and void.
  • Promise.all and Promise.allSettled have been updated to use mapped type instead of $TupleMap. The requirement on the type arguments are slightly changed.

Don't miss a new flow release

NewReleases is sending notifications on new releases.