Skip to content

Releases: facebook/flow

v0.335.0

Choose a tag to compare

@SamChou19815 SamChou19815 released this 09 Oct 03:11

Breaking Changes:

  • Removed the legacy builtin_lib=flowlib and builtin_lib=flowlib-with-lib-dom-d-ts options.
  • 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, and saved_state.reinit_on_lib_change. These options had been enabled by default and only accepted true.

Likely to cause new Flow errors:

  • Symbol and Promise now 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.replaceAll now has separate overloads for a replacement string and a replacer function, matching TypeScript. Passing a union of these types is an error.
  • RegExpMatchArray.groups is now optional and cannot be null, and RegExp.prototype.dotAll is read-only, matching TypeScript.
  • new $ReadOnlyArray now causes an error.
  • Symbol() now only accepts a string | number description, and Symbol.keyFor returns string | 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.PropsOf now uses React.ComponentProps to 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 undefined type can be used in library definitions, where it means void.
  • flow-remove-types supports abstract classes, abstract members, override modifiers, satisfies, optional class fields, and additional type-only imports and exports.
  • Template literals infer precise types in const declarations and annotated initializers.

Notable bug fixes:

  • as const on template literals infers template literal types like TypeScript.
  • Implicit instantiation can infer a type argument through React.ComponentProps and other conditional types with infer.
  • Interfaces with construct signatures no longer print a spurious this parameter in error messages and hovers.
  • this-typed methods inherited from builtins such as typed arrays now return the subclass.
  • Exported declare class declarations extending builtins such as Error, Map, Set, or Date now inherit the builtin's statics and constructor.
  • Arguments of new X(...) are now contextually typed when X is annotated with the typeof of a constructor interface value.
  • typeof x === 'function' now refines builtin constructors such as Map and Symbol, 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 asserts call signatures.
  • instanceof and declare class ... extends now use the prototype of a constructor interface that has no construct signature, instead of narrowing to empty or 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.ElementConfig is deprecated in this version and will be removed in the next version. Use React.ComponentProps instead.
  • The unnecessary-invariant lint is renamed to unnecessary-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 null and void separately instead of "null or undefined".
  • Record type utility errors name the utility (Partial, Required, or mapped type).

Parser:

  • Store abstract property annotations in typeAnnotation and emit value: 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, and Date now 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.ComponentProps in generated type annotations.

Library Definitions:

  • React.ComponentProps<'div'> now includes the optional ref prop.
  • Added Promise.withResolvers.
  • The type parameters of Map.groupBy are now ordered <K, T>, matching TypeScript.
  • RegExp.prototype[Symbol.matchAll] is now a method and RegExpStringIterator an interface, matching TypeScript.

v0.334.0

Choose a tag to compare

@SamChou19815 SamChou19815 released this 02 Oct 04:17

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.

v0.333.0

Choose a tag to compare

@SamChou19815 SamChou19815 released this 24 Sep 15:49

Likely to cause new Flow errors:

  • Imports of react module will always resolve to Flow's builtin react type definitions. If you use a custom react typing module, you might see errors.

Notable bug fixes:

  • Preserve Flow WASM linker settings, including memory growth.
  • Correct parser ranges for unique symbol types and signed mapped-property variance.

Parser:

  • Rename the ImportType ESTree field from argument to source.
  • Preserve computed object type property keys in parser output.

Library Definitions:

  • Flow will now include DOM typing from TypeScript's lib.dom.d.ts by default. If your project is not supposed to run in the browser, you can switch back to the old behavior with builtin_lib=core-only in flowconfig's [options] section.
  • Flow's Iterable and ArrayLike type now align with those from TypeScript. You might see errors when your existing code assumes the old typing.

v0.332.0

Choose a tag to compare

@SamChou19815 SamChou19815 released this 19 Sep 00:38

Breaking Changes:

  • no_flowlib option is removed. Use builtin_lib=flowlib (default) or builtin_lib=prelude instead.

Likely to cause new Flow errors:

  • Render types no longer accept exact react element as arguments. See https://flow.org/en/docs/react/render-types/ for supported cases
  • Flow will now always infer a react jsx element to be a render type if it's an element of a component-syntax component, or React.MixedElement otherwise. Legacy code that requires exact react element will see new errors.
  • Add an option for rejecting dynamic imports in Haste modules.

New Features:

  • Symbol() and Symbol.for() create a unique symbol when they initialize a const, so symbols can be used as property keys without explicit declarations.

Notable bug fixes:

  • Bound error type normalization to prevent excessive memory use
  • Release temporary signature-hash graphs after Flow merges.
  • Using import typeof of a generic value without type arguments keeps its polymorphism instead of reporting missing-type-args, and renders accepts import typeof of a generic component.

Parser:

  • Parse deferred imports: import defer * as ns from "m" and import.defer("m") now set the ESTree phase property to "defer".

IDE:

  • Hover on members accessed through super shows the declaration
  • Hover on destructuring keys shows the member declaration
  • Hover on enum members shows the member declaration
  • Hover on signature labels and indexer keys shows the parameter
  • Hover on component attribute names shows the prop declaration
  • Hover on import/export sources shows the module
  • Hover on this-parameters shows the parameter
  • Hover on indexed-access literals shows the member
  • Hover on polymorphic JSX elements no longer exposes overly precise literal types when no annotation demands that precision
  • Hover on a call to an overloaded function reports how many other signatures the function has
  • Hover lists the signatures of an overloaded declaration instead of printing their intersection
  • Component hovers no longer drop indexer rest props
  • Align multiline union members in hover type declarations
  • Render hover definition links in a compact Rust-style navigation row.
  • Expand rest-prop aliases in top-level component hovers.

Library Definitions:

  • React ref callbacks now have a stricter return type
  • import.meta will no longer have url property and arbitrary unknown property. To add them back, you can do so through declaration merging (e.g. adding interface ImportMeta { url: string } to your global library definitions.
  • ArrayLike and ArrayBuffer now follow TypeScript definitions
  • Stricter typing for Array(length) and Array(items)

v0.331.0

Choose a tag to compare

@SamChou19815 SamChou19815 released this 04 Sep 00:29

Likely to cause new Flow errors:

  • Fixed unsound subtyping of instances against indexer in interfaces (example).
  • Flow will no longer emit method-unbinding errors and instead perform stricter this-type checking (example).

IDE:

  • Improve the primary type displayed by hover
  • Show a single type in type-at-pos and hover
  • Truncate oversized hover types and their reference lists

Library Definitions:

  • React.ReactElement now matches latest type in @types/react. Added missing React.JSX.Element that makes the type in @types/react .

v0.330.0

Choose a tag to compare

@panagosg7 panagosg7 released this 31 Aug 22:59

Likely to cause new Flow errors:

  • Flow will now restrict the allowed syntax forms of .call/apply/bind calls. Only expressions of the form <expr>.m.call(<expr>, ...), <expr>.m.apply(<expr>, ...) and <expr>.m.bind(<expr>, ...) are allowed.
  • [untyped] section of flowconfig will use the glob system. See https://flow.org/en/docs/config/untyped/

Notable bug fixes:

  • Fixed #9407.
  • Support instanceof refinement of constructor objects.
  • Operations like Partial no longer strip readonly-ness of dictionaries. (example)

v0.329.0

Choose a tag to compare

@gkz gkz released this 22 Aug 19:25

Likely to cause new Flow errors:

  • More subtyping errors will print the types that are incompatible. Some errors might have new locations.
  • A unique symbol annotation is now an error unless it is the type of a const variable, of a readonly object type or interface property, or of a static readonly class field.
  • Flow will error on legacy variance syntax in library definition files

New Features:

  • We have released flow-parser and flow-eslint packages that are drop-in replacement for hermes-parser and hermes-eslint. Babel docs and ESLint docs have been updated.
  • Object properties, class fields, methods, and the members of an interface or declare class imported from another module, can be keyed by a unique symbol.

Notable bug fixes:

  • Prevent a race that can leave server hanging
  • Support TypeScript constructor objects in Flow class positions.
  • keyof over a symbol index signature is now symbol rather than string.
  • A class can extend a value with a construct signature.
  • x !== undefined no longer stops refining after a call that passes undefined as an argument: (e.g. try-Flow)

Library Definitions:

  • Well-known symbols on Symbol are typed as unique symbol, and Symbol.metadata is now available.

v0.328.0

Choose a tag to compare

@mvitousek mvitousek released this 14 Aug 22:22

Breaking changes:

New Features:

  • this type guards can now be used on non-static methods of regular classes, not just declare class and interface methods. The method body is checked for consistency against the guard type.

Notable bug fixes:

  • Prevent cached IDE results from blocking rechecks.

Library Definitions:

  • Allow symbols to be used as WeakMap keys

v0.327.0

Choose a tag to compare

@SamChou19815 SamChou19815 released this 12 Aug 16:09

New Features:

  • In an object type, a bracketed key written as a string or number literal, or as the name of a value, is now a computed key naming a single property rather than an index signature, so several such keys can coexist. A key written as a type-only name is unchanged, and the labeled form [label: K] keeps index-signature semantics. Breaking: a key headed by a value binding is read as a computed key. Thus a class or enum key such as {[C]: V} is now an error, and a qualified type exposed through a class/namespace merge, as in {[C.K]: V}, must use the labeled form {[key: C.K]: V} to remain an index signature.
  • In an interface or a declare class body, a bracketed key written as a string or number literal, or as the name of a value, is now a computed key naming a single property rather than an index signature, so several such keys can coexist, and static puts the property on the static side. A key written as a type-only name is unchanged, and the labeled form [label: K] keeps index-signature semantics. Breaking: a key headed by a value binding is read as a computed key, so a class or enum key such as interface I {[C]: V} is now an error and must use [key: C] to remain an index signature.
  • A computed method key [expr](): T that resolves to a single literal string or safe-integer number is now accepted in interface, declare class, and object type bodies (previously a parse error outside .d.ts files) and reads as a named method.
  • A bracketed access on an array with a string-literal key (for example arr['map'] or arr[Symbol.iterator]) now reads the corresponding named member instead of erroring that the key is not an array index, and a string key holding a safe integer (arr['0']) indexes the array like the equivalent numeric key.

Notable bug fixes:

  • keyof any now evaluates to any as expected. Spurious errors related to the bug will no longer fire.
  • Fix a server crash ("thread 'flow-tokio-runtime' has overflowed its stack") when rechecking a file with an attached LSP client

Parser:

  • Parse component and hook type annotations as the declaration of declare export default

Library Definitions:

  • Add ES2026 Map methods

v0.326.0

Choose a tag to compare

@SamChou19815 SamChou19815 released this 05 Aug 21:29

Breaking changes:

  • The following flags are removed since they no longer change anything
    • experimental.channel_mode
    • experimental.channel_mode.windows
    • experimental.long_lived_workers
    • experimental.long_lived_workers.windows
    • gc.worker.custom_major_ratio
    • gc.worker.custom_minor_max_size
    • gc.worker.custom_minor_ratio
    • gc.worker.major_heap_increment
    • gc.worker.minor_heap_size
    • gc.worker.space_overhead
    • gc.worker.window_size
    • sharedmemory.hash_table_pow
    • sharedmemory.heap_size

Likely to cause new Flow errors:

  • General subtyping errors will print the types that are incompatible. Some errors might have new locations.