Releases: facebook/flow
Releases · facebook/flow
v0.239.0
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 ofC
instead of the constructor definition. Hovering onC
will still show the jsdoc on the constructor. - Strip
as const
casts andas
casts inflow-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()
andpop()
on anArray<T>
will now returnT | 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
tohttps$Server
v0.238.3
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
Notable bug fixes:
- Fixed a bug where a recheck triggered by
flow force-recheck
doesn't respectfiles.implicitly_include_root=false
config. - Fixed a bug that causes missing results in find-ref and rename.
v0.238.1
This release is used to test the release automation powered by GitHub Actions. No changes are expected.
v0.238.0
Likely to cause new Flow errors:
- In v0.237.2, we shipped the flag
react.disable_function_components_default_props
that will make Flow ignoredefaultProps
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 populatex
, 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
anduseActionState
API definitions - Add libdef for
TextDecoderStream
v0.237.2
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 ignoredefaultProps
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
Notable bug fixes:
- Fixed an issue that might cause connecting to flow server to fail with out of retries.
v0.237.0
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
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 rightReact.createElement
typing, and check whether the locally defined React has the rightReact.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 withstring
. - 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 withflow-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 providecomponent
andhook
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 liketypeof $await
, you can replace it with<T>(Promise<T> | T) => T
.
v0.235.1
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)