Releases: facebook/flow
Releases · facebook/flow
v0.290.0
Likely to cause new Flow errors:
- flow will now validate variance in interface declarations
- Bad cyclic object types are now banned. e.g.
type O_loop = { p: 0, __proto__: O_loop }will cause an error. - Flow is now stricter with generic mapped type. example
Notable bug fixes:
- We improved the refinement system of match. Some code that previously gets a general type will now get a refined type. example
- allow opaque types to be used as keys to computed object properties
- autocomplete on
import { | } from 'a';will only suggest values, not types. - flow-dev-tools now properly detects unused suppressions
IDE:
- Flow now provide auto-import code actions for all unbound names, even through they might resolve to a global. It can be helpful when the global is not what you want.
Library Definitions:
- Add bigint functions to DataView
v0.289.0
Likely to cause new Flow errors:
- For a poorly bounded generic indexed access types, we will no longer generate an error for it when it's being first subtyped against. Instead, we will make it opaque so that when it's being subtyped against, it will error. example
- Flow will error when you are trying to redefine the following reserved types:
$NonMaybeType,NonNullable,$ReadOnly,Readonly,$Keys,$Values,Values,$ReadOnlyMap,ReadonlyMap,$ReadOnlySet,ReadonlySet.
Notable bug fixes:
- We no longer incorrectly report conditional hook call for loops with a break. example
- Fixed a potential crash when evaluating a conditional type. example
- Flow will now allow computed keys of type
StringPrefix/StringSuffixto be included in object initializers with other non-overlapping keys (example try-Flow)
Library Definitions:
- Update React API types from recent releases
Added
act: 19.0: https://react.dev/reference/react/actcaptureOwnerStack: 19.1: See https://react.dev/reference/react/captureOwnerStackuseEffectEvent: 19.2: https://react.dev/reference/react/useEffectEvent<Activity />: 19.2: See https://react.dev/reference/react/Activity
UpdateduseDeferredValue: 19.0: Accepts a second argument for initial valueuseTransition: 19.0: Accepts an async action functionstartTransition: 19.0: Accepts an async action function
v0.288.0
Likely to cause new Flow errors:
React.ElementPropsis removed. You should useReact.ElementConfiginstead.- For a function named as a hook but not annotated as a hook, it will no longer be treated like a hook when you try to use it from property access or property destructuring in component syntax components and hook syntax hooks. They will now cause
react-rule-hook-non-hook-syntaxerrors. To fix, annotate them with hook annotation. example - Calling functions passed to function and component with hook like name but not annotated as hook will now error. example.
React$RefSetter<...>and andReact$Contextare removed. It continues to be available in the form ofReact.RefSetter<...>andReact.Context<...>, regardless of whether you have importedReact.React$ElementRef<...>was removed. It continues to be available in the form ofReact.ElementRef<...>, regardless of whether you have importedReact.
Breaking Changes:
- The config option
max_literal_lengthwas removed. Flow will always decide whether to infer a specific or general type of string literal based on the natural inference algorithm.
Notable bug fixes:
- You can now use
@@disposeand@@asyncDisposein your library typings. You can access the respective properties withobj[Symbol.dispose]andobj[Symbol.asyncDispose]. - Allow comparisons of bigint singletons
Library Definitions:
- The second type argument of
ExactReactElementwill be populated byReact.ElementConfig<C>instead ofReact.ElementProps<C>. Most of the code that doesn't depend on exact react element types won't be affected.
v0.287.0
Breaking Changes:
- We will stop publishing new versions of flow-parser-bin. If you want to parse flow code with native-like performance, you should use
hermes-parserpackage, which is running on wasm.
Likely to cause new Flow errors:
- The deprecated
React$Elementtype is now removed. You should useReact.NodeorReact.MixedElementin most cases. If you really want exact react elements, you can useExactReactElement_DEPRECATED
New Features:
- Flow has full React 19 ref-as-prop support. Since this version, you are allowed to spread ref prop in component syntax components.
IDE:
- We now provide a rewrite refactor to convert arrays, map, set, and object types into their readonly forms.
v0.286.0
Breaking Changes:
- Starting from this version,
flow-binwill only contain ARM64 binaries for macOS.
Likely to cause new Flow errors:
- Flow now errors on constant conditions and invalid comparisons. example
- Flow will no longer infer an unsound type for array and object literals passed to a general function. example
React.ElementConfig<...>andReact.PropsOf<...>will now always include the ref prop in the props object type.- The config option for an earlier mode
react.ref_as_prop=partial_supportis removed, and Flow now has better support for React 19's ref-as-prop behavior:- All the ref prop in component syntax components must be made optional
- You might need to rewrite some of your higher order components. e.g. previously an identity HOC must be written as
declare function id<Props: {...}, Ref>(c: component(ref?: Ref, ...Props)): component(ref?: Ref...Props)
now it must be written as
declare function id<Props: {...}>(c: component(...Props)): component(...Props)
v0.285.0
Library Definitions:
- Fix type of
useActionStatehook in React. Type should beAwaitedinstead ofPromise(the opposite operation). - Added types for
Object.groupByandMap.groupBy
Bug fixes:
- Fixed a bug that when
experimental.ts_utility_syntax=true, importedReadonly,ReadonlyArray,NonNullable,ReadonlyMap,ReadonlySettypes are considered any.
v0.284.0
Likely to cause new Flow errors:
- Flow now strictly enforces that Array.includes, .indexOf, and .lastIndexOf take only values that could potentially be present in the array -- it is now an error to check if arrays include values whose types are unrelated to the array's element type. This catches many cases where developers accidentally test the wrong thing, which may lead to errors at runtime.
- Flow will infer general types for react jsx elements. The new behavior is described in the docs.
v0.283.0
Likely to cause new Flow errors:
- Invalid suppressions like
// $FlowFixMe[incompatiblewill now cause an error on the suppression
v0.282.0
Likely to cause new Flow errors:
- Multiple object property invariant subtyping errors on the same object will be combined into one error. Some error locations might be moved.
Notable bug fixes:
- Fixes crash happening on exported functions with signatures of the form
<X>(x: X, y: typeof x): T
IDE:
- We now provide a best effort quickfix for some invariant subtyping errors.
Library Definitions:
Array.findcan now return a more precise value if the predicate is inferred to be a type guard. example
v0.281.0
Breaking Changes:
- Support for the
casting_syntax=colonis removed. This means that the as casting syntax is always enabled. experimental.error_code_migrationconfig option is removed. In the previously version, the only allowed value wasnew.
Likely to cause new Flow errors:
- We have fixed more source of object literal unsoundness. More errors will be exposed. (example)
- For most of the common invariant subtyping errors (arrays, objects with mutable fields), we will now emit a single subtyping error with explanation how to fix. Error locations might change. See https://flow.org/en/docs/lang/variance/#toc-invariance to learn more about variance of types
- Suppressions without error code will now be an error instead of a warning.
- Suppressions without error code will no longer apply. You can download and use this script to automatically migrate most of the suppressions.
- Only
$FlowFixMeand$FlowExpectedErrorare supported suppression comments. Existing$FlowIgnoreand$FlowIssuewill no longer suppress anything.
New Features:
- Added a Flow lint
require-explicit-enum-checkswhich works likerequire-explicit-enum-switch-casesbut formatch.
Notable bug fixes:
- Various codemods will now insert parentheses around expressions in class extends if they are changed. Previously, it might result in invalid code like
class Foo extends myExpr() as Bar - Fixes an inconsistency in recording the this-type guard on a regular (non-
declare) method in the same vs different files.
IDE:
- Added a quickfix to convert type to value imports on type-as-value errors.