Skip to content

Releases: facebook/flow

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)

v0.236.0

09 May 20:10
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • Ensure React class component constructors call super with a props object. example
  • Modified typing of React.cloneElement. You might see errors being shifted around, and some advanced patterns no longer supported. The API is not encouraged by React, so migrating away from it is recommended.
  • For JSX elements under react.runtime=classic, we now type check the JSX unconditionally using the right React.createElement typing, and check whether the locally defined React has the right React.createElement definition. If you have some JSX that's already invalid, you might see different errors. example
  • React$CreateClass type, aliased to any since v0.176, is removed.
  • Fix typing of isValid Flow Enums method, reverting back to behavior from before v0.232.
  • Support for $CharSet, an undocumented feature, has been removed. RegExp$flags, which depends on $CharSet, is also removed. In most cases, you should replace these types with string.
  • Support for --traces and the corresponding flowconfig option has been removed.
  • React.createFactory libdef is removed. This API is already deprecated and will be removed in React 19.

Notable bug fixes:

  • Fixed interactions of various types with specialized versions of mixed (such as $NonMaybeType<mixed>). (try-Flow examples)

Misc:

  • Support removing export type * (ExportAllDeclaration) nodes with flow-remove-types (thanks @jbroma!)

Parser:

  • Updated bigint literal AST output for bigint property to match ESTree spec. Numeric separators are removed (_), and should contain only decimal digits.

IDE:

  • Under component_syntax=true, autocomplete will provide component and hook keyword in appropriate places.

Library Definitions:

  • $asyncIterator, which is never a real global, is removed from global libdef.
  • We removed $await in the libdef. If you are depending on it like typeof $await, you can replace it with <T>(Promise<T> | T) => T.

v0.235.1

24 Apr 04:07
Compare
Choose a tag to compare

Likely to cause new Flow errors (copied from 0.235.0 release notes):

  • Flow's react-rule enforcement now detects reads from ref.current within nested functions of hooks and components that are called during rendering.
  • obj[key] where obj is not a dictionary object and key is a string used to not error and just silently return any. We now error on this pattern.

Misc:

  • By default, flow ast will now parse component syntax rather than reject it. You can pass --no-component-syntax to get the old behavior (D56501290 samzhou19815)