Likely to cause new Flow errors:
- We changed the upper bound of
React.Elementto 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 ofReact.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
AinA extends B ? C : Dis 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 emitsignature-verification-failure.
New Features:
- Hovering on enum members in IDE now show documentation if it's available.
- Added
casting_syntaxoption which can becolon(current),as, orboth. If setting isboth, both(x: T)andx as Tare allowed. If set tocolonoras, only(x: T)andx as Tare 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.Elementtypes. Instead, it will insert general types likeReact.MixedElement.
Library Definitions:
- Add type definition for
CanvasRenderingContext2D.roundRect. - Add
tagNameto DOM element declarations (thanks @aselbie).