Skip to content

Releases: facebook/flow

v0.240.0

17 Jul 16:50
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • We fixed a bug that causes Flow to incorrectly believe that the LHS of logical operators are not nullable. example
  • Flow can now detect more kinds of bad cyclic types. (example)
  • Flow will now consistently catch some invalid comparison of the kind obj.type === 'foo'. example
  • Fixed a bug in the type guard refinement that involves sentinel properties (e.g. try-Flow)
  • Function.prototype.apply and Function.prototype.call are now typed using userland types instead of hardcoded builtin support. You might see slight inference differences, error message and code changing as a result.
  • Flow now enforces that only function types are assigned to the .constructor property of object types. (D58538540 pvekris)
  • Fix subtyping checks of unions of bigint types against other unions of bigints.
  • Make array holes be typed as void, not empty.

New Features:

  • You can now pass in an (optional) second type argument to the StringPrefix utility type. This is the type of the remainder of the string after the prefix is removed. For example, "$1", "$2" are subtypes of StringPrefix<'$', '1' | '2'>, but "$999" is not. StringPrefix<X> is equivalent to StringPrefix<X, string>
  • You can use the $Values utility type to get the type of the elements of an array type or tuple type.
  • You can now do sentinel refinements on tuples, like you can already do for objects. This is especially useful for function arguments (you can type the ...args as a union of tuples). [example]
  • Sentinel refinements now work when using number keys on objects [example]
  • Flow now keep original type after invalid object prop-exists refinement on write-only property.

Notable bug fixes:

  • Some operations can now be performed on an opaque type with appropriate bounds. example
  • Fixed a bug that occurs when you have a tuple type spread after two or more non-spread arguments. Those will now be resolved in the correct order.

Library Definitions:

  • String.codePointAt now returns number | void

v0.239.1

08 Jul 19:52
Compare
Choose a tag to compare

Notable bug fixes:

  • Fixed a bug where IDE services doesn't respect files.implicitly_include_root=false config.

v0.239.0

03 Jul 19:53
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • We now detect errors when props of React components using component syntax, or hook argument/return values of React hooks using hook syntax, contain arrays, sets, or maps that are mutated using their methods (Array.push, Set.add, Map.set, etc). These values are expected to be read-only, and we previously errored on directly setting their props; this release extends this enforcement to method calls as well.
  • We are adding more strict checking for type guard functions to account for the refinement happening in the else branch of conditionals that use them (see docs for more information). You might see new errors appear in the declaration of type guards. One way to address these is by turning the type guard definition to one-sided, by adding implies before the type guard (example try-Flow)

New Features:

  • The StringPrefix type represents strings which being with the specified prefix. E.g. StringPrefix<'data-'> allows for 'data-floo' and 'data-bar'. The type argument for this type must be a string literal. [example]
  • Flow now supports globalThis.

Notable bug fixes:

  • Fixed an issue since 0.232.0 that will cause failure to connect to Flow server if libdef has parse errors.
  • Made the "extract to function" refactoring more robust to errors during code synthesis.
  • Fixed a bug that can cause hover to hang forever for recursive namespaces. example
  • Go-to-definition on new C() will jump to definition of C instead of the constructor definition. Hovering on C will still show the jsdoc on the constructor.
  • Strip as const casts and as casts in flow-remove-types

IDE:

  • Hover will show a list of all the symbols found in the inferred type and the locations where they are defined. VSCode LSP and CLI are supported. The LSP version includes a link to the definition. The CLI version only shows the name of the file (no path)

Library Definitions:

  • Calling shift() and pop() on an Array<T> will now return T | undefined.
  • Add cause property on Error instance; Support error cause in error constructor options
  • Add type definition for FinalizationRegistry
  • Add type definition for CSSSupportsRule
  • Add closeAllConnections, closeIdleConnections to https$Server

v0.238.3

27 Jun 16:53
Compare
Choose a tag to compare

Misc:

  • In v0.238.1 and v0.238.2, we have bumped the required GLIBC version to v2.35 on Linux. We have now reduced the requirement to v2.31 for x86_64 build of Linux.

v0.238.2

26 Jun 23:33
Compare
Choose a tag to compare

Notable bug fixes:

  • Fixed a bug where a recheck triggered by flow force-recheck doesn't respect files.implicitly_include_root=false config.
  • Fixed a bug that causes missing results in find-ref and rename.

v0.238.1

18 Jun 06:14
Compare
Choose a tag to compare

This release is used to test the release automation powered by GitHub Actions. No changes are expected.

v0.238.0

13 Jun 23:31
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • In v0.237.2, we shipped the flag react.disable_function_components_default_props that will make Flow ignore defaultProps on function components for React component typing purposes. This flag is now on by default. If this is too disruptive for your codebase, you can turn this off for now. Note that we do not intend to keep this flag forever, so you should try to turn this flag on as soon as possible.
  • We made React.createElement have an opaque type, which means calling this function directly will be an error. This will be helpful to prepare for React 19 changes. Note that JSX typing is unaffected. If you are not ready for this change, you can override your library definition like this to approximate the previous behavior as much as possible.
  • When there is an invalid-component-prop error, Flow will no longer make the entire props to be any type. Instead, Flow will create a Props type as if these invalid props do not exist. example
  • We are making the typing of the exported object of a module more strict. If you see errors when casting the exported type of a module to a writable object, try either casting it to a readonly version instead, or casting the exported object to the writable object type.
  • We now infer the type for Object.freeze({ A: "a", B: "b" }) as {+A: "a", +B: "b"}, ie we use readonly properties and singleton types for literal initializers. Casts like this example will now be an error.
  • We now error more consistently when a property is missing from an intersection of objects (e.g. try-Flow)
  • untyped-import errors are now on the import source rather than imported names.

New Features:

  • Under files.implictly_include_root=false (default is true, which is the current behavior), Flow will no longer include everything under the directory where the flowconfig is in by default.

Notable bug fixes:

  • Fixed a category of spurious errors when using Array.reduce and returning a union type (e.g. try-Flow)
  • Explicit type arguments in JSX are now considered for contextual typing. example
  • Fixed spread of empty array when calculating tuple elements, e.g. [...[]] as [] now works.
  • nested-component errors can now be suppressed.

IDE:

  • Flow now suggests properties of objects that are contextually typed with optional types. For example, in ({ foo: { | } } as ?{ foo: { x: number }}) it will populate x, when calling autocomplete at the point of the cursor |. (try-Flow)
  • We now provide autocomplete for types in the global React type-only namespace.
  • We now support go-to-definition for JSX member expression like <Foo.Bar />.
  • Re-exported values from export {Foo} from 'bar' statements will now appear in autoimport results.
  • autoimports_ranked_by_usage is now enabled by default.
  • Flow will now show the type of the constructor of a class (instantiated if it is generic) when hovering over the "new" keyword in new C(e)
  • Hover types will now show the specialized version of a polymorphic component used at a JSX expression
  • Hover types won't add unnecessary parentheses around union types.

Library Definitions:

  • Add React 19 useOptimistic and useActionState API definitions
  • Add libdef for TextDecoderStream

v0.237.2

04 Jun 02:57
Compare
Choose a tag to compare

New Features:

  • We added a flag to help prepare your codebase for React 19's defaultProps change. defaultProps on function components will no longer work in React 19. Under react.disable_function_components_default_props=true, Flow will ignore defaultProps on function components for React typing purposes. Note that we do not intend to keep this flag forever, so you should try to turn this flag on as soon as possible.

v0.237.1

29 May 18:38
Compare
Choose a tag to compare

Notable bug fixes:

  • Fixed an issue that might cause connecting to flow server to fail with out of retries.

v0.237.0

29 May 05:50
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • Flow will no longer break up a union argument when calling an overloaded function. The code in this try-Flow will now be an error.

New Features:

  • Under jest_integration=true, Flow will now error on some jest mocking APIs (e.g. jest.mock('./my-module')) if the module doesn't exist.

Notable bug fixes:

  • Fixed spread of empty array when calculating tuple elements, e.g. [...[]] as [] now works.
  • Fixed inferred type of React.ElementConfig/Props when passed in a component syntax component (e.g. try-Flow)