github meta/flow v0.219.0

latest releases: v0.337.0, v0.336.0, v0.335.0...
3 years ago

Likely to cause new Flow errors:

  • We changed the upper bound of React.Element to be an inexact empty object, effectively making it opaque.
    React doesn't recommend inspecting children and React.Element, so we make the change to increase friction. See https://react.dev/reference/react/Children#alternatives for alternatives.
    To keep existing code type safe, you can add a function like the following to explicitly expose the internal of React.Element:
export default function DangerouslyAccessReactElementInternals_DO_NOT_USE_IN_NEW_CODE<
  E: React$ElementType,
  P,
>(e: React$Element<E, P>): {
  +key: React$Key | null,
  +props: P,
  +ref: any,
  +type: C,
} {
  return e;
}
  • Conditional types will now only distribute over a union if A in A extends B ? C : D is a generic type. This is a behavior change that might cause new errors (example). Previously, we distribute over unions in more cases, which contradicts what we said in the docs, and caused some weird behavior that's fixed in this version.
  • If an exported class contains unannotated propTypes, Flow will now emit signature-verification-failure.

New Features:

  • Hovering on enum members in IDE now show documentation if it's available.
  • Added casting_syntax option which can be colon (current), as, or both. If setting is both, both (x: T) and x as T are allowed. If set to colon or as, only (x: T) and x as T are allowed respectively.

Notable bug fixes:

  • Previously, when Flow cannot decide which branch to take in a generic conditional type, Flow will produce a abstract type that's unusable almost everywhere. Now Flow will still produce an abstract type, but it will be bounded above by a union type of both branches of conditional type. example.

Misc:

  • Flow's insert type quickfix in IDE will stop inserting very specific React.Element types. Instead, it will insert general types like React.MixedElement.

Library Definitions:

  • Add type definition for CanvasRenderingContext2D.roundRect.
  • Add tagName to DOM element declarations (thanks @aselbie).

Don't miss a new flow release

NewReleases is sending notifications on new releases.