Repository navigation
Releases
v0.343.0
Likely to cause new Flow errors:
voidfollows TypeScript semantics by default and is distinct fromundefined.experimental.ts_voidonly acceptstrue. Runflow codemod migrate-to-ts-voidto help migrate existing code.- Two instantiations of an object type with an index signature are now compared by their index signatures, which can surface errors that were missed.
- Refinements of component and hook props, and other read-only unions, now look into type alias and
Valuesmembers; this can surface errors that were missed. - Exponential-spread errors no longer name the same union operand twice. An error for a spread with a maybe-typed operand can be reported at another operand, as it is for the explicit union.
- Spreads,
Readonly,Partial, React configs and object rest no longer drop the members of a union or intersection that contains another one, which can surface missed errors. - A generic or opaque value passed for a
T | null | voidparameter is narrowed as for?T:Tno longer takes in thenullandvoidof its bound or supertype. - Spread arguments of calls are now contextually typed by the params they fill, like plain arguments, so array literals and callbacks in spread position keep their precision and no longer need annotations. A spread argument can now report the errors the same expression gets as a plain argument.
newof a class whose TypeScript declaration declares a constructor now gives the instance instead ofany- A type
import("m").Xread from another file is no longeranywhenXis a type or has type arguments, and is the instance type whenXis a class, also a class merged with a namespace. - A class extending an intersection, such as tsc's mixin output, now inherits from what its construct signatures return, with the whole intersection as its statics.
- A call can leave out the argument for a trailing element of a fixed-length tuple rest param that accepts
undefined, likeg()forg(...args: [x: void]). Too few or too many arguments for such a rest param are reported as for params (requires another argument,extra-arg) instead ofinvalid-tuple-arity.
New Features:
- Library declare-module blocks will now go through declaration merging.
Notable bug fixes:
- Props can narrow the event of a React event handler they inherit, as in TypeScript.
- Recursive type aliases whose type arguments grow as object, intersection or template literal types no longer hit the recursion limit or overflow the stack.
- Fixed stale errors and a crash after rechecks where a change reaches checked files through node_modules, or a file's imports stop resolving
- Fixed stale duplicate module provider errors after a new provider takes over a Haste module
- Fixed missing and stale package.json parse errors after rechecks
- Values of an opaque type's lower bound now flow into the opaque type after an operation narrows it, when they fit the narrowed type.
- Under
experimental.ts_void, a function that returns no value in one branch of a conditional no longer drops the annotation hint of the other branch. - Refinements, such as sentinel property checks,
inandtypeof, now narrow an opaque type's upper bound and keep the opaque type, as they do for a type parameter. - A type parameter that a call gives no evidence for no longer mentions the other type parameters of the signature in its inferred type.
- When library files declare overloads of the same interface method, the overloads of the one merged later, such as a
[libs]file over a builtin, are tried first. - A library in
[libs]can override a declaration of a bundled.d.tsbuiltin, as it can for the other builtins. - Builtin overloads are tried in TypeScript's order, and Flow's fallback overloads, such as
toSpliced<S>, after TypeScript's. - Changing a file in an import cycle of two files rechecks the files that depend on the cycle
- A
nullorundefinedargument for aT | null | voidparameter givesTanemptybound, as for?T. - Implicit instantiation no longer infers
null | voidfrom aT | null | voidvalue whoseTis not inferred yet. - An element passed to a prop of type
(renders T) | nullinfers its type arguments fromT, as for?renders Tor an optional prop. - With
experimental.normalize_intersections, an intersection of unions withnullandvoidmembers is normalized as one of maybe types is. - An interface in a
declare namespacecan extend another member through the namespace's name without the namespace becomingany - Rechecks no longer miss errors in the dependents of a file whose
requireswitches between modules that a library declares. - Overloaded generic methods declared in TypeScript are compared with their type parameters erased, as in TypeScript.
Omitand other object type utilities no longer give an interface's index signature value to props declared elsewhere on itsextendschain, e.g. an inheritedonFocuswhen the interface has a[key: `data-${string}`]signature.- Error messages no longer print
?for a type with many overloads of a method. - Fixed a crash on a mapped type whose keys refer to the mapped type
- Implicit instantiation infers type arguments through a conditional type whose check type indexes a type parameter, e.g. Lexical's
Klass<T> - A type parameter of a TypeScript-declared generic that no part of a call reaches takes its default or bound, as in TypeScript, instead of being reported as underconstrained.
- Exported mapped types and
keyofover intersection keys such asstring & {}no longer fail signature verification - A conditional type kept abstract over a type parameter now sees the type parameter narrowed by the extends type in its true branch
keyofand mapped types over a class declared in a.d.tsfile now include its methods and inherited members.typeof M.Xandtypeof import("m").Xread a value thatMexports withexport type, as in TypeScript.newon aClassofReadonly<I>,Partial<I>or another sliced interface with aconstructormethod no longer reports thatconstructoris missing.thisin the type parameter bound of adeclare classmethod no longer errors withillegal-this.- A tuple type can end with a spread of a type parameter bounded by a union or intersection of arrays, or of an undecided conditional type whose branches are arrays
- In a tuple type written in TypeScript, spreads of arrays followed by other spreads of arrays or optional elements become one rest element, as in TypeScript
- Read-write elements of TypeScript tuples, including tuple types with spreads, are now compared covariantly, as in TypeScript.
- Class and interface declarations accept getters and setters with computed keys, such as
get [Symbol.toStringTag]() - Fixed a stack overflow on recursive conditional types that stay undecided over a type parameter, like the path types of
react-hook-form - A computed key in a type can name a value imported with
import type, as in TypeScript - Recursive type aliases whose type arguments grow as spread tuple types no longer overflow the stack
export default <name>inside a librarydeclare module, as written in TypeScript.d.tsfiles, now declares the module's default export.- A type parameter bounded by
keyof Tcan index an object keyed bykeyof T, such asRecord<keyof T, V>, whenThas no object bound - An error about an argument from a spread whose type is written in another file is reported at the call instead of in that file.
- Fixed stack overflows and recursion limit errors on property lookups through classes whose base reaches the class itself.
typeofand keys in types read the value of an export that is both a type and a value throughimport type, as in TypeScript- A homomorphic mapped type over an intersection with an array or tuple member, such as a type parameter bounded by
Iterable<unknown> & ReadonlyArray<unknown>, no longer errors - A call of a TypeScript generic under the hint of an enclosing generic call, such as
useState(() => f()), gives a type parameter that nothing reaches its default or bound, as in TypeScript. - Fixed the constructor and member precedence of a class extending a mixin applied to a class, and restored the error codes for classes extending other intersections.
Misc:
- Errors about the keys of an intersection name the union of its keys.
IDE:
- Hover on a type alias looks through aliases of other aliases, and Go to Definition on a qualified type, like
M.Xwithimport * as MorReact.Node, goes to the member's declaration instead of staying on the reference or going to a global with the same name - Hover and error messages print a type declared in a library
declare namespaceunder its qualified name, likeReact.MixedElementorIntl.NumberFormatOptions - Fixed autocomplete, go-to-definition and hover for members of a class extending an intersection or another value with construct signatures.
Library Definitions:
Iterator,IterableandIterableIteratornow defaultTReturnandTNexttoany, as in TypeScript.IteratorObjectnow defaultsTReturnandTNexttounknown, as in TypeScript.- Built-in iterators (arrays, maps, sets, strings, enum
members()) returnundefinedwhen done, as in TypeScript withstrict. - Add the
react/jsx-runtimeandreact/jsx-dev-runtimemodules and React'sFunctionComponentElementandDetailedReactHTMLElementtypes from@types/react
v0.342.0
Likely to cause new Flow errors:
- A failed attempt to match a member of a union no longer changes the types that later attempts see, which can find errors that were missed. (e.g. try-Flow)
- Flow now infers the type arguments of a generic call by matching its arguments and its expected type against the signature directly, rather than by solving temporary type variables through subtyping. Some inferred types change, and some errors move from an argument to the place where the call's result is used.
- Errors about a type application (a type that is not polymorphic, a value used as a type) are now reported once, where the application is written, including for applications of generic type parameters and of
any-typed values untyped-type-importerrors are now always on (the lint was on by default already). Delete references to the lint in your.flowconfigandflowlintcomments — the setting is a no-op for this release and will be removed in a future release.internal-typeerrors are now always on (the lint was on by default already). Delete references to the lint in your.flowconfigandflowlintcomments — the setting is a no-op for this release and will be removed in a future release.invalid-this-argerrors are now always on (the lint was on by default already). Delete references to the lint in your.flowconfigandflowlintcomments — the setting is a no-op for this release and will be removed in a future release.libdef-overrideerrors are now always on (the lint was on by default already). Delete references to the lint in your.flowconfigandflowlintcomments — the setting is a no-op for this release and will be removed in a future release.nested-componenterrors are now always on (the lint was on by default already, butall=warn,all=offor an explicit setting could weaken it). Delete references to the lint in your.flowconfigandflowlintcomments — the setting is a no-op for this release and will be removed in a future release.nested-hookerrors are now always on (the lint was on by default already, butall=warn,all=offor an explicit setting could weaken it). Delete references to the lint in your.flowconfigandflowlintcomments — the setting is a no-op for this release and will be removed in a future release.unsafe-object-assignerrors are now always on (the lint was on by default already, butall=warn,all=offor an explicit setting could weaken it). Delete references to the lint in your.flowconfigandflowlintcomments — the setting is a no-op for this release and will be removed in a future release.react-intrinsic-overlaperrors are now always on and can no longer be turned off with lint settings. Suppress them with$FlowFixMe[react-intrinsic-overlap]. Delete references to the lint in your.flowconfigandflowlintcomments — the setting is a no-op for this release and will be removed in a future release.T[K]of an optional property now includesvoid; some errors involving optional properties are reported at different locations or with different codes.
New Features:
undefinedis always accepted as a type annotation.experimental.undefined_typeonly acceptstrue.
Notable bug fixes:
- An interface that extends a type alias whose type parameters all have defaults no longer loses the members it inherits when imported
- Type references inside a
declare namespaceblock now resolve classes, enums and values declared in the namespace's other blocks, as they already did when the declaration was imported - A callback parameter's hint no longer includes
voidfrom members of a union hint that do not take the parameter. - Arguments of
yield,yield*andreturnin annotated generators are now checked with the annotation as a hint, as in TypeScript, andAsyncGeneratoris covariant in its yield and return types likeGenerator. - Testing a property against a union of literals that includes
nullorundefinedno longer drops members whose property isnullorvoid. Underexperimental.ts_void, testing a property againstundefinedor a literal narrows away members whose property isvoid. - Under
experimental.ts_void, fixed a spuriousmissing-local-annoton a callback whose call has another callback that returns no value. - Type-argument errors on
newof a value with a construct signature are reported at thenewexpression instead of the signature's declaration. Promise.resolve()returnsPromise<void>, and a return hint no longer makes an overloaded call fail when an overload accepts its arguments.
Misc:
- Document the
flow-upgradepackage on flow.org.
v0.341.0
Likely to cause new Flow errors:
keyofof a union now evaluates to the keys that every member has, matching TypeScriptimport typebinds every meaning of the export, as in TypeScript:typeofanddeclare classheritage can read the imported value, and importing a value that is not a type is no longer an error (using it as a type is)- Unnamed function type parameters, unlabeled dictionary keys and the explicit exact object type syntax
{| |}are always errors.flow-upgradepackage provides codemod to migrate the codebase. - Assignments in the part of an optional chain that
?.can skip no longer count as definitely run after the chain. Object.definePropertycalls with a string-literal key are checked against the library signature, as in TypeScript: the descriptor must be aPropertyDescriptor, a type argument is the type of the object, and the object no longer has to declare the propertyObject.definePropertiescalls with an object literal are checked against the library signature, as in TypeScript: the descriptors must be aPropertyDescriptorMap, and the object no longer has to declare the properties- A value of an opaque type is now checked against the narrowed upper bound of the same opaque type.
- Type arguments are checked where the type application is written, including in generic definitions, instead of where a type is instantiated
Notable bug fixes:
keyofof an intersection now includes the keys of every member that is an objectkeyofof an interface declared in a.d.tsfile now includes its methods.- Unions and object spreads whose parts each apply the same type alias no longer evaluate to
emptyfrom four members or five operands on. - Fixed slow checks of types that nest mapped types, such as
OmitofOmit. - In the true branch of
T extends U ? X : Y,Tis known to satisfyU keyof Tis a subtype ofkeyof Tfor a type parameterTwithout a bound- Preserve signed mapped optionality when translating Flow declarations to TypeScript.
- Names in a
declare namespaceblock that merges into a declared function or class now resolve to the exports of the earlier blocks instead ofany. - A conditional type, such as
Exclude<keyof T, K>, acceptskeyof Tof a type parameterTthat has no object bound - A type parameter is now a subtype of a union that its bound is a subtype of, and a type parameter bounded by an intersection is now a subtype of a union that contains it.
- A generic whose bound is an intersection now fits an intersection that contains that generic.
- An object literal whose computed key is a type parameter now has that type parameter as its key type instead of the parameter's bound.
- A type parameter whose bound is a polymorphic function type keeps matching itself after being passed to a hook or used as a React prop.
- Optional chaining,
NonNullableand optional indexed access now see through an opaque type's upper bound and keep the opaque type, as they do for a type parameter. matchbindings now keep a type parameter or opaque type, with its bound narrowed by earlier patterns, instead of the members of its bound.- The file crawl no longer hangs on directory symlinks that link packages into each other's
node_modules, as pnpm does for workspace packages.
Misc:
- Document abstract classes, class member overrides and
no_implicit_override, template literal types, constructor types, unique symbols, mapped key remapping and signed modifiers,satisfiesexpressions, and inline import type annotations.
Parser:
- The location of an abstract class method now includes its trailing semicolon.
IDE:
- Go-to-definition on the property of a qualified
typeoftype (e.g.foointypeof obj.foo) now jumps to the property's definition - Hover on a call to a polymorphic function prints the declared signature, with the types it computes evaluated for the call, and the instantiation's type arguments in a section of their own
Library Definitions:
React.ReactElement,React.ElementRef,React.PropsWithoutRef,React.ReactManagedAttributesandDistributiveOmitnow declare the bounds of their type parameters- The
getandsetmembers ofPropertyDescriptorare declared as optional methods, as in TypeScript Object.getOwnPropertyDescriptorsreturns a descriptor typed per property, as in TypeScriptObject.create(proto, properties)returnsany, as in TypeScript
v0.340.0
Likely to cause new Flow errors:
- Class component configs are computed with
React.ReactManagedAttributes - Errors on keys read from
keyofover an object with an indexer are now reported at the use of the key instead of at the indexer - Arguments of
Objectstatic method calls that Flow doesn't type specially now get contextual types from the method's signature, like other method calls. use()calls in functions that Flow can't place in a component or hook now get thereact-rule-hook-conditionalerror code instead ofreact-rule-hook.- JSX intrinsics are typed by
React.JSX.IntrinsicElementsinstead of$JSXIntrinsics, which Flow no longer reads.experimental.jsx_intrinsic_elementsonly acceptstrue. - Class component configs always merge default props with
React.ReactManagedAttributes.experimental.react_managed_attributesonly acceptstrue.
New Features:
- Support fractional and other finite numeric property keys in Flow, using JavaScript property-name stringification.
Notable bug fixes:
!= nulland truthiness refinements removenullandundefinedfrom unions with optional or nested maybe members also when the union is optimized- Truthiness and falsiness refinements filter intersection members represented by chains of type variables
- Methods of an interface with a construct signature, such as
Number.isFiniteandDate.parse, can be read without their receiver, like class statics. - Reading
prototypefrom a function or a callable object that doesn't declare it givesany, as declared by the builtinFunction, instead of aprop-missingerror - Preserve nominal and intrinsic render types in match pattern bindings.
flow-nodeno longer drops script arguments that equal a Node option passed before the script path.flow-upgradeadds thenameFunctionTypeParamsandnameIndexerKeyscodemods, andremoveExplicitlyExactObjectTypeSyntaxalso removesambiguous-object-typelint comments.
Parser:
- Parse TypeScript's definite assignment assertions on class fields,
value!: T, and variables,let x!: T - Fixed parse time that doubled with each level of nested conditional expressions with parenthesized consequents
PropertyDescriptorandPropertyDescriptorMapare now interfaces, as in TypeScriptObjectis now declared asinterface Object+interface ObjectConstructor, as in TypeScriptFunctionis now declared asinterface Function+interface FunctionConstructor, withCallableFunctionandNewableFunction, as in TypeScript
v0.339.0
Breaking Changes:
- Rename
typeParameterstotypeArgumentson ESTreeGenericTypeAnnotation,InterfaceExtends, andClassImplements, including WASMflow-parseroutput. Declaration parameters and Babel output retain their existing names. PropertyDescriptorandObject.getOwnPropertyDescriptorare no longer generic. Remove type arguments fromPropertyDescriptor<T>annotations andObject.getOwnPropertyDescriptor<T>(...)calls.
Likely to cause new Flow errors:
- Hook calls in classes now use
react-rule-hook-class, and calls in deeper nested anonymous callbacks inside components or hooks usereact-rule-hook-conditional, instead ofreact-rule-hook. Update suppressions to the new codes. Hook calls directly in class property initializers are also rejected when the enclosing function would otherwise permit them. - Assignments and throws in function or component parameter defaults and destructuring defaults are now treated as conditional, because a default only runs when the value it replaces is
undefined. - Property increments and decrements (
o.x++,o.x--,++o.x, and--o.x) now invalidate narrowings of the property through aliases, as assignments already do. - Reads in an assertion call's condition now use the types at the point where they run, rather than types after the call and its later arguments. This removes false errors and reports reads before a later argument assigns a variable.
break,continue,return, andthrowpaths throughfinallyare no longer dropped. Flow now reports variables left unassigned and narrowings that do not hold on these paths.- Optional class fields (
x?: T, withexperimental.tslib_syntax) now have typeT | void. Reads may returnundefined, and assigningundefinedis allowed. - Type parameters explicitly declared
in outin TypeScript files are now invariant rather than covariant. - Functions named
use*declared in TypeScript files are now treated as hooks. This fixes calls from Flow hook syntax, but calls outside a component or hook can now report Rules of Hooks errors. parseInt,parseFloat, andevalnow require astring;isNaNandisFiniterequire anumber; and builtin Error constructors require astringmessage, matching TypeScript.Object.getOwnPropertyDescriptor,Object.defineProperty,Object.prototype.hasOwnProperty, andObject.prototype.propertyIsEnumerablenow requirePropertyKey(string | number | symbol) keys.PropertyDescriptorMapis also keyed byPropertyKey.DataView.byteLengthandbyteOffset, numeric typed arraybyteLength,byteOffset, andlength, andRegExp.source,global,ignoreCase, andmultilineare now read-only.RegExp.prototype.compilenow requires a pattern.Array.prototype.spliceuses separate removal and insertion overloads, so inserting items requires adeleteCount.ArrayandReadonlyArrayreduceandreduceRightnow have an overload whose initial value and accumulator use the element type. Calls intending a different accumulator type may need an explicit type argument, e.g.reduce<number>(...).Promise.prototype.thenandcatchnow use TypeScript-style signatures.thenhas separate fulfillment and rejection type parameters; calls whose inferred result is unsuitable may need explicit type arguments.RegExpMatchArray.indexandinputare now optional, and its first element is declared as0: string. Check optional fields onmatchresults, and useRegExpExecArrayforexecandmatchAllresults.Error.stackis now optional, matching TypeScript.- Numeric typed array
subarraymethods, includingUint8Array.prototype.subarray, return their corresponding typed array rather thanthis. Subclasses that return their own type should declare their own override.
New Features:
- Format code with Prettier in the Try Flow playground, and copy JSON from its AST view.
- Object type spreads allow optional properties after an object with an indexer. Value spreads retain their existing checks.
- Add
translateFlowTypeToTSTypetoflow-api-translatorfor type-node translation. - Functions with any return type are accepted where a TypeScript-declared function type returning
voidis expected, matching TypeScript. Flow-declared function types retain their existing return checks.
Notable bug fixes:
- Fixed Windows commands such as
flow checkhanging when their output is piped or captured, even after the command exits (#9519). - Preserve imported TypeScript template literal types without requiring
experimental.tslib_syntax. - Type guards refine distinct bigint literal types to
empty, as they already do for string, number, and boolean literals. - Fixed an internal error when a function parameter default always throws; the function is now typed and checked.
- JavaScript objects with extra properties can be checked against TypeScript object types whose index signature applies to only some keys, and against interfaces extending an object type with an index signature.
- Accept literal initializers such as
declare const x = -1. - Improve implicit instantiation through conditional types without
infer, conditional types nested inside distributive conditional types, and type applications that expand to types mentioning the inferred parameters. - Fixed a crash when a mapped type's key has the same name as a type parameter spread in the mapped object type.
- Imports such as
.//fooand..//fooresolve like./fooand../foo. - Prevent stack overflows and spurious internal errors when checking recursive tuple spreads in generic type arguments.
- JavaScript subclasses can override static methods of TypeScript classes with narrower parameters, as on the instance side.
- Fixed a crash on a
matchin unreachable code. - Fixed a crash when a namespace merged with a class or function redeclares one of its members.
- Fixed crashes when a recheck is canceled while checking a component declaration, or when cancellation or a timeout interrupts a type cast from an annotated source.
- Fixed a crash on a method with a
thisparameter in a class expression or a class declared in a callback. - Fixed a crash when a file imports a name that it also declares as a function, component, or hook.
- Fixed crashes when a library definition stops parsing while the server is running, or contains an ignored statement that reads a name, such as
f();. - TypeScript enum checking no longer requires
enums=true. - Fixed a crash ("Non speculating: LimitExceeded") when destructuring a value whose type lookup exceeds the recursion limit.
- A type parameter whose bound mentions another type parameter no longer leaks unresolved into the other parameter's solution.
- A field named
constructor, including TypeScript's['constructor']fields, now typesx.constructorwithout shadowing the constructor used bynewandsuper(). - Named imports work from CommonJS modules whose
module.exportshas multiple call signatures or is an overloaded function merged with a namespace. - Mapped types with template literal keys now produce individual properties when their placeholders resolve to string literals, instead of retaining a template literal indexer. Generic placeholders and unsupported intersection or recursive-alias cases retain their existing behavior.
flow-upgradetransformations preserve type arguments with both legacy and current parser AST fields.
Misc:
- Implements errors print the implemented interface's type and type arguments instead of generic descriptions such as "exports".
- Try Flow disables Clear and Copy code when the editor is empty, keeps the Format button stable as saved-state controls change, and places the AST format selector after its hide options.
- Tooling documentation recommends
flow-parserand Prettier's built-in Flow parser without an external parser plugin.
Parser:
Programsource locations and ranges span the entire input, including whitespace and comments.flow-parserpreserves optionality on constructor parameter properties.- Correct
flow-estreetypes for unannotated object type properties, readonly type operators, combinedin outvariance, optionalProgram.tokens, sparse-array elements, and JSX namespaced attributes. Sparse-array parent repair and traversal preserve holes. - Omit absent
typeoftype arguments from ESTree output, including WASM-decoded nodes and detached builders. - Default interface exports have the correct type-only export kind and AST typings. Type stripping removes the complete export wrapper rather than leaving a dangling
export default. flow-parsertype stripping preserves function parameter defaults and side-effect imports.flow-transformpreserves leading#!lines.flow-eslintscope analysis handles TypeScript parameter properties, class member decorators, anddeclare global.- Type translation preserves readonly array and tuple operands, inline interface bodies, and qualified interface bases.
- Type translation tracks required React imports for JSX-qualified types.
- Strict TypeScript translation rejects unsupported generic indexer keys instead of silently losing qualification or type arguments. Recovering string-API behavior is unchanged.
IDE:
- Hover on calls to polymorphic functions, including functions bound by
const, properties, or parameters, and on construction of polymorphic classes shows the instantiated type arguments. - Multiline unions and intersections in hover types are indented under their annotation, one member per line.
- Hover,
dump-types, and error messages printanywithout its kind, e.g.anyinstead ofany (explicit).
Library Definitions:
encodeURIComponentalso accepts numbers and booleans.Symbol.prototype.valueOfreturnssymbolinstead of?symbol.arguments.calleeandFunction.prototype.callerare typed asFunction, and functionprototypeproperties a...
v0.338.0
Breaking Changes:
- Flowconfig option
experimental.assertion_functionsis removed. Assertion functions have been on by default and the option only acceptedtruesince 0.337. - Flowconfig option
experimental.disable_invariant_special_casingis removed. It has been on by default and only acceptedtruesince 0.337. - Flowconfig option
experimental.function_and_object_type_is_no_longer_anyis removed. It has been on by default and only acceptedtruefor a while. - Flowconfig option
experimental.builtin_ts_libdef_dynamic_discoveryis removed. It has been on by default and only acceptedtrue. - Flowconfig option
experimental.declare_global_supportis removed. It has been on by default and only acceptedtrue.
Likely to cause new Flow errors:
Readonly,Partial,Required,$Exact,Omitand mapped types over an interface now include its methods and the members it inherits.- Type guards now refine
Array<any>,{data: any},Map<string, any>and similar types to the guarded type, e.g.Array<string>, which can surface errors in code that relied onany. - Static members can no longer reference the type parameters of their class, like in TypeScript, and reading a static member of a generic class no longer infers them.
keyofof an object with a template literal indexer no longer widens the indexer key tostringin conditional types likeExclude.
New Features:
- Mapped types over arrays and tuples support
readonlyandwriteonlymodifiers. - Property truthiness checks such as
if (result.done)now refine unions of classes and interfaces by fields with literal types, as===checks already did. - Type guards narrow through optional calls such as
isString?.(x). When the callee or receiver is nullable, only the true branch narrows. - Support optional assertion calls when their declared types guarantee the call runs.
- Added the intrinsic
ExactObjectType, the supertype of every exact object type and a subtype of{...}.
Notable bug fixes:
- Fix crashes and false recursive-definition errors from cyclic type star exports in TypeScript declarations.
- Support namespace export aliases and ambient exported members in TypeScript definitions.
- Allow classes to extend a constructor whose overloads are not all generic, such as
Uint8Array<ArrayBuffer>. - Casting a value whose type intersects an enum with other types (e.g.
E & E) to the enum's representation type no longer errors. - Arrays can be assigned to variables and parameters whose type was inferred from
new Array<T>(...). - Report delegated yield type errors at the yield expression.
- Align Try Flow's default lints and
declare globalsupport with regular Flow. - Improve inference for generic values passed to polymorphic operations.
- Fix Try Flow initialization after the async builtin migration while preserving older releases' library definitions.
- Report conditional type instantiation errors at the caller.
- Apply type-parameter defaults when omitted optional or nullable arguments are the only evidence for them.
- An object with an indexer is no longer checked against optional properties it doesn't declare of a TypeScript-declared (
.d.ts) object type, matching TypeScript. - Fewer
underconstrained-implicit-instantiationerrors for generic calls passed as arguments to other generic calls. - Fixed a crash when printing long types that contain non-ASCII names in error messages.
- Tuple types with a spread keep the variance of their own elements, e.g.
ain[readonly a: unknown, ...T]stays read-only. Firstin[infer First, ...infer Rest]is now inferred instead ofunknown.- Fixed a deadlock in the Flow server monitor that could make all subsequent commands fail with "Out of retries, exiting!".
- Type guards with a union type now refine union members precisely, e.g. a falsy-value guard on
string | numberrefines to"" | 0. - Type guards now drop union members that are instances of classes unrelated to the guarded class, e.g.
x: A | Brefined byx is Ais nowArather thanA | (A & B). - The negative branch of a type guard now refines away generics that satisfy the guard, e.g.
x: T | numberrefined by!isT(x)withisT: (x: unknown) => x is Tis nownumber. - In the negative branch of a type guard,
anynow staysanyinstead of becomingempty, andbooleanis refined to the literal the guard does not cover. - Correct stdin behavior for
flow check-contentsandflow autocomplete. - Error messages print code that contains backticks, such as template literals, as markdown code spans.
- Instances of TypeScript-declared generics, such as
React.MouseEvent<T>, now compare type parameters without a variance annotation covariantly, as type applications already did. - Type guards now drop tuple members of a different length and array members with disjoint element types.
- Type guards now drop object and interface union members whose properties conflict with the guard type.
x instanceof Cno longer refines a value of an intersection type toempty.- Linux release builds use jemalloc, which keeps the memory of long-running servers from growing after large rechecks.
- Fixed a race that could leave a file unmerged after a recheck, which made the server recheck forever while an open file imported it.
Misc:
- Print rest arrays as array types in errors.
- Print receiver and merged declaration types in errors.
- Simplify missing this annotation diagnostics.
- Print both types in inheritance errors.
- Identify missing parameter annotations directly at the parameter location.
- Remove empty filename metadata from the Try Flow AST display.
- Add a default-on option to hide locations in the Try Flow AST pane.
- Show node types first in the Try Flow AST pane.
- Add a default-on option to hide null and undefined fields in the Try Flow AST pane.
- Move Try Flow's JSON error output into an Errors format pill bar.
- Add JSON AST output to Try Flow.
Parser:
- Accept explicit semicolons on shorthand ambient modules.
- Accept keyword members in qualified type names and import types.
- Allow repeated inline interface exports in TypeScript files.
- Fixed
flow-parsertaking minutes to parse JS files over ~1 MB. - Support destructured rest parameters in function type signatures.
- Support import attributes on re-export declarations.
- Preserve TypeScript accessibility modifiers on bodyless class method signatures.
- Preserve computed type-literal keys as properties in TypeScript source files.
- Allow newline-separated type members in TypeScript source files.
- Use
"in out"for the ESTree variance kind ofin outtype parameters. - Parse postfix non-null assertions with type syntax enabled, preserve ASI, and emit TypeScript-compatible
NonNullExpressionnodes. - Respect JavaScript line terminators and Unicode whitespace when recovering source locations.
- Parse default interface exports and report unsupported syntax during type checking.
- Correct inferred ESTree source type for default interfaces, inline type specifiers, and exported import aliases.
- Exclude default interface exports and all-type specifier lists from inferred Babel module source type.
- Support top-level await for explicit modules and
.mjs/.mtsfiles in flow-parser. - Always enable type parsing for TypeScript filenames.
- Reject type syntax in untyped parser mode and report precise diagnostics.
- Fix declaration method signature locations to include the complete signature.
- Include the
constkeyword in const enum declaration locations.
IDE:
- Hover and error messages no longer print redundant parentheses around function types in maybe types, e.g.
?() => voidinstead of?(() => void).
Library Definitions:
- Align well-known symbol members (
Symbol.toStringTag,Symbol.match,Symbol.toPrimitive, ...) with TypeScript. MapandWeakMapset, andSetandWeakSetadd, now returnthis.RegExpflags/sticky/unicodeandNumber.EPSILON/MAX_SAFE_INTEGER/MIN_SAFE_INTEGERare now read-only;String.prototype.normalizeaccepts the normalization form literals and the legacy HTML methods (bold,link, ...) are declared.Array.prototype.copyWithinreturnsthis, so subclasses ofArraykeep their type.Array.prototype.sortreturnsthis, so subclasses ofArraykeep their type.Mathconstants (Math.PI,Math.E, ...) are read-only.Number.MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITYandPOSITIVE_INFINITYare read-only.String#splitrequires a separator,String#replacehas separate overloads for a string and a function replacement, andString#lengthis read-only, as in TypeScript.- Use TypeScript's ES2018 async iterator and iterable definitions.
- Use TypeScript's ES2018 async generator definitions.
- Use TypeScript's ES2019 array definitions while preserving Flow's existing
flatMapunion order and inference. - Use TypeScript's ES2020 promise definitions, including mutable settled results.
- Use TypeScript's ES2016 array
includesdefinitions while keeping Flow's element refinement. - Use TypeScript's ES2015 generator definitions.
Generator.prototype.returnnow requires a value of the generator's return type. - Add
React.CSSProperties, typed bycsstype. - Use TypeScript's ES2015 promise definitions, adapted to Flow's inference.
- Use TypeScript's ESNext set method definitions, including
Set.prototype.union. - Use TypeScript's ES2015
Map,Set,WeakMapandWeakSetdefinitions.sizeis now read-only. doneis now optional in the non-final branch ofIteratorResult, as in TypeScript.- Use TypeScript's ES2015 iterable definitions.
ArrayIterator,MapIterator,SetIteratorandStringIteratorare now interfaces, andStringIteratortakes a type argument. - Add React's DOM types from
@types/react, such asReact.MouseEvent,React.HTMLAttributesandReact.JSX.IntrinsicElements. React.ComponentPropsof a string that is...
v0.337.0
Likely to cause new Flow errors:
Function.prototype.bindis now typed with TypeScript'sCallableFunction.bindoverloads, so errors in bound arguments are reported atbind, and a bound function's remaining parameters are a tuple type.FunctionandObjectno longer meananyand no longer triggerunclear-typeerrors. They are now interpreted as the prototypes of functions and objects. Code that assumed they meantanymay get new errors.- Internal type
Function$Prototype$Bindis removed. - Class method
bindnow uses the declaredFunction.prototype.bindoverloads. Bound methods may now report tuple arity errors when used as callbacks that ignore extra arguments or omit nullable parameters, because their inferred parameters are represented as tuple rest parameters.
New Features:
- Support assertion functions. If you relied on Flow's special handling of
invariant, give it anassertssignature. - Execute runtime Flow syntax in CommonJS and ES modules with original stack locations through
flow-node. - Support assertion narrowing through
thisandsuper, including receiver assertions. Readonlynow supportsArrayandReadonlyArraytypes.
Notable bug fixes:
- Honor opaque upper bounds in template interpolation and nullable subtyping.
- Preserve nominal opaque inference when checking nullable targets.
- Fixed spurious
Recursion limit exceedederrors when checking conditions,matchand other expressions whose type is a trivially recursive generic type alias. - Prevent unsound assertion narrowing when annotations refer to shadowed local declarations.
- Qualified type references through a union of namespaces (e.g.
(cond ? A : B).Tvia a local) now look up the type in each namespace instead of reporting it as missing. - Prevent saved-state startup and incremental match checking from crashing when a recheck is canceled.
Misc:
- Document assertion functions.
Parser:
- Add missing AST fields and node types to the Flow parser output.
implicitDeclareis now omitted unlesstrue. - Emit
TypeParameter.boundas a bare type node ornullin ESTree output. Babel output retains theTypeAnnotationwrapper, and the TypeScript-to-Flow API translator generatesextendsbounds. - ESTree enum declarations now use a unified
EnumBodynode with string-or-nullexplicitType. Babel output retains its existing enum body types. - Parse typed function overload signatures in TypeScript implementation files.
- Parse destructured parameters in TypeScript function types outside declaration files.
- Parse optional class method signatures in JavaScript and TypeScript files.
- Parse optional TypeScript constructor parameter properties.
- Parse namespace export aliases and ambient exported members in TypeScript definitions.
- Fix parsing of class modifiers before synchronous generator methods.
- Support
readonly T[]in unlabeled tuple elements and require parentheses when optional.
Library Definitions:
- Add
Intl.SegmenterandIntl.supportedValuesOf. - Add
Intl.NumberFormat.prototype.formatRangeandformatRangeToParts, and the ES2023NumberFormatoptions;formatacceptsbigintand numeric strings. String.prototype.localeCompare,toLocaleLowerCaseandtoLocaleUpperCaseacceptIntl.LocalesArgument;matchAllwith aRegExpreturnsRegExpExecArraymatches.Float16Array.prototype.toLocaleStringtakesIntl.NumberFormatOptions.- Add ES2024
ArrayBufferresizing, transfer, and constructor options. - Align
ReflectAPIs with TypeScript property, descriptor, key, and constructor definitions. - Reuse TypeScript's
Float16Arraydeclarations while preserving Flow covariance and callback compatibility. - Align
ProxyAPIs with TypeScript and check array elements against numeric interface indexers.
v0.336.0
Likely to cause new Flow errors:
- Calls such as
Array.fromcan now infer narrower literal types, requiring explicit annotations where broader types are needed. Unconstrained class type arguments now use their bounds instead ofempty. - Flow now checks
refcompatibility for JSX tags typed asstring, exposing refs that assume a more specific element type. - Explicit
thisparameters on methods in library definitions no longer need to accept the instance type. - Generic rest-parameter inference can now expose previously hidden parameter-type errors. For example,
(input: string, ...args: Array<unknown>) => voidno longer satisfies(...args: TArgs) => RwhenTArgsis inferred asArray<unknown>(Try Flow example). - Rest destructuring of exact tuples, e.g.
const [first, ...rest] = t, now excludes preceding elements' types fromrest. - Variance annotations are now checked through tuple type spreads, so
type T<out X> = [string, ...[X]]is an error.
New Features:
- Support tuple types with trailing rest elements, e.g.
[string, ...Array<number>]. Array literals ending in array spreads and arguments collected by rest parameters can flow to these types.
Notable bug fixes:
- Declaration merging for interfaces and
declare classnow preserves variance annotations. - Returns inside functions nested in a type guard function are no longer checked against the enclosing type guard.
- References inside
declare namespaceblocks now see members merged across blocks and library files. - Functions and constructors are now accepted as builtin
FunctionandObjectvalues. - Fixed spurious indexed-access errors involving recursive class type-argument bounds.
- Type arguments used in later tuple spreads, e.g.
Bin[...A, ...B], are now inferred instead of left underconstrained. - Conditional types using
inferon rest parameters now preserve the matched function's optional parameters and rest element in the inferred tuple, e.g.[number, ...Array<boolean>]. Matching functions with fewer parameters than the pattern and no rest parameter no longer produces underconstrained errors.
Misc:
flow-upgradenow uses Flow parser packages and requires Node 18 and Prettier 3.
Parser:
- Correct JavaScript source columns after characters represented by surrogate pairs.
IDE:
- Hover
Go tolinks no longer include the hovered declaration itself.
Library Definitions:
Intlis now a builtin namespace with TypeScript-compatible definitions through ES2020, includingCollator,NumberFormat,DateTimeFormat,PluralRules,RelativeTimeFormat,Locale,DisplayNames,getCanonicalLocales, andformatToPartsfor dates and numbers.- The legacy
Intl$CollatorOptions,Intl$DateTimeFormatOptions, andIntl$NumberFormatOptionsaliases now match TypeScript.Intl.DateTimeFormatPartTypesincludes'unknown', and locale-awareDatemethods acceptIntl.LocalesArgumentandIntl.DateTimeFormatOptions. - The global
LocalesArgumenttype is nowIntl.LocalesArgument. Library declarations such as flow-typed'sdeclare var Intlhide the builtin namespace and must be removed. React.ElementConfigis removed; useReact.ComponentPropsinstead.- Typed arrays gain
findLast,findLastIndex,toReversed,toSorted, andwith, and their constructors can be called without arguments. For types other thanFloat16Array,findLastnarrows its result with a type-guard callback. Callbacks tofindLastandfindLastIndexcan no longer annotatethis. Float16Arraynow matches TypeScript's declaration, including itsfromoverloads.length,byteLength, andbyteOffsetare read-only,findandfindIndexpredicates must returnboolean, and callbacks can no longer annotatethis.- Add RegExp indices and flags, well-formed string methods, bigint Atomics,
Error.isError,Promise.try,Atomics.pause, and additional ArrayBuffer and Date constructor signatures. - Add TypeScript signatures for
Array.fromAsync. AggregateError.prototype.errorsis now typedany[], matching TypeScript.- Decorator definitions now match TypeScript:
ClassDecoratoraccepts classes, decorator context and metadata types are available, andFunctionincludes[Symbol.metadata]. - Add
DisposableStack,AsyncDisposableStack,SuppressedError,Disposable, andAsyncDisposable.AsyncGeneratornow extendsAsyncIteratorObjectand includes[Symbol.asyncDispose].
v0.335.0
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.
v0.334.0
Likely to cause new Flow errors:
- Improved generic type inference with conditional types. Some places might infer a different type and cause new errors.
Number,String,RegExp,Date, native errors, maps, and sets now use TypeScript-style instance and constructor interfaces, while Math, JSON, and Atomics use named interfaces. Existing code relying on their previous class or object typing may produce new errors.
New Features:
- Allow object type spreads over interfaces and inexact object types.
Notable bug fixes:
- Allow classes to extend generic construct-signature interfaces.
- Generic values re-exported through annotated CommonJS getters retain their polymorphic types.
- Preserve record lowering source locations.
- Preserve match lowering source locations.
Parser:
- Support semicolonless abstract method declarations.