Breaking Changes:
- Removed the legacy
builtin_lib=flowlibandbuiltin_lib=flowlib-with-lib-dom-d-tsoptions. - Removed the Flow config options
exact_by_default,experimental.always_generalize_jsx,experimental.fast_symlink_resolution,experimental.importable_global_libdefs,experimental.interface_dictionary_typing_fix,experimental.new_this_typing,experimental.opaque_type_new_bound_syntax,saved_state.allow_reinit,saved_state.direct_serialization, andsaved_state.reinit_on_lib_change. These options had been enabled by default and only acceptedtrue.
Likely to cause new Flow errors:
SymbolandPromisenow use TypeScript-style instance and constructor interfaces. Code relying on their previous class typing may see different errors.- Some JSX expressions that were previously considered underconstrained now infer
unknown. - Fixed type argument inference that incorrectly used a bound or
unknown. More underconstrained errors may appear. String.prototype.replaceAllnow has separate overloads for a replacement string and a replacer function, matching TypeScript. Passing a union of these types is an error.RegExpMatchArray.groupsis now optional and cannot benull, andRegExp.prototype.dotAllis read-only, matching TypeScript.new $ReadOnlyArraynow causes an error.Symbol()now only accepts astring | numberdescription, andSymbol.keyForreturnsstring | void, matching TypeScript.- Deprecated syntax now consistently causes errors, including in library definition files.
- Type arguments of a polymorphic value flowing to a non-polymorphic type are now solved, which can surface previously hidden errors.
React.PropsOfnow usesReact.ComponentPropsto find component props. Additional errors may occur.
New Features:
- Support assertion functions exported through CommonJS, assertion calls in return position, and assertion calls in arrow expression bodies.
- The
undefinedtype can be used in library definitions, where it meansvoid. flow-remove-typessupports abstract classes, abstract members, override modifiers,satisfies, optional class fields, and additional type-only imports and exports.- Template literals infer precise types in
constdeclarations and annotated initializers.
Notable bug fixes:
as conston template literals infers template literal types like TypeScript.- Implicit instantiation can infer a type argument through
React.ComponentPropsand other conditional types withinfer. - Interfaces with construct signatures no longer print a spurious
thisparameter in error messages and hovers. this-typed methods inherited from builtins such as typed arrays now return the subclass.- Exported
declare classdeclarations extending builtins such asError,Map,Set, orDatenow inherit the builtin's statics and constructor. - Arguments of
new X(...)are now contextually typed whenXis annotated with thetypeofof a constructor interface value. typeof x === 'function'now refines builtin constructors such asMapandSymbol, and interfaces with call signatures, as functions.- User-defined assertion conditions check member access in test context.
- Recognize ESM default imports of CommonJS assertion functions and callable objects with
assertscall signatures. instanceofanddeclare class ... extendsnow use theprototypeof a constructor interface that has no construct signature, instead of narrowing toemptyor reporting "not inheritable".- Fixed a memory leak in type signature parsing that inflated server memory on large codebases.
- Fixed checking interfaces that extend classes, including object values and multiple generic class supers.
Misc:
React.ElementConfigis deprecated in this version and will be removed in the next version. UseReact.ComponentPropsinstead.- The
unnecessary-invariantlint is renamed tounnecessary-assertion; the old name is still accepted. - Constructor errors and variance check errors now print types instead of descriptions such as "object type", "module", or "exports".
- Unary arithmetic on a maybe-typed operand reports
nullandvoidseparately instead of "null or undefined". - Record type utility errors name the utility (
Partial,Required, or mapped type).
Parser:
- Store abstract property annotations in
typeAnnotationand emitvalue: null.
IDE:
- Hover on flow.org/try now shows types framed as declarations, matching the VS Code extension.
- Autocomplete and go-to-definition on instances of classes extending builtins such as
Map,Set,Error, andDatenow show the builtin's instance members. - JSX attribute autocomplete on a union or intersection of components offers the props of the components the element is checked against.
- Go-to-definition on a JSX attribute of a union or intersection of components uses the props of the components the element is checked against.
- Find-references on a JSX attribute of an intersection of components finds the attributes passed to the branch the element is checked against.
- Qualify
React.ComponentPropsin generated type annotations.
Library Definitions:
React.ComponentProps<'div'>now includes the optional ref prop.- Added
Promise.withResolvers. - The type parameters of
Map.groupByare now ordered<K, T>, matching TypeScript. RegExp.prototype[Symbol.matchAll]is now a method andRegExpStringIteratoran interface, matching TypeScript.