Releases: facebook/flow
Releases · facebook/flow
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)
v0.234.0
Likely to cause new Flow errors:
- Flow might catch more inexact incompatible with exact errors. example
- Fixed a bug that leads to Flow sometimes ignoring differences in call props of an object. New errors might be exposed. example
- We rewrite the way we generate types for annotations. We will now detect and error on trivially recursive types like
type T = T
ortype Foo = typeof foo; const foo: Foo = ...
. In addition to this, you might see some errors being moved around. - Fixed Flow Enums exhaustive checking logic when input is a generic.
- Invalid indexed access types with string index, like {foo: string}[string], will now error instead of silently making it
any
.
New Features:
- You can have a tuple spread of a generic in the parameter of a function and not have to supply the relevant type argument if that spread is the only spread in that tuple, and it is the last element of that tuple.
- Negative numbers are now allowed in Flow Enum values.
- Allow Flow Enums to be cast to their representation type when the cast expression is typed as a generic type.
- Added a new global type
EnumValue<>
, which represents all Flow Enum values. You can constrain the enum values to those with a particular representation type by supplying the type argument, e.g.EnumValue<string>
. - Added a new global type
Enum<>
, which represents all Flow Enums (this is a complement to the newEnumValue
type). You can constrain the enums to ones which have a particular enum value, e.g.Enum<>
is the same asEnum<EnumValue<>>
, and the type of all enums with string representation types isEnum<EnumValue<string>>
. These "abstract enums" have no know members, so you can't access members or exhaustively check them, but you can use methods such as.members()
,.cast()
, etc. - Allow
===
comparison of abstract Flow Enums as well as Enums themselves with the same ID. - You can now cast Flow Enum values to their representation type using
.valueOf()
, e.g.enum E {A, B}; const s: string = E.A.valueOf()
.
Notable bug fixes:
- We now error more reliably in the matching property tests, for example when the object part is a complex expression. example
- Fixed spurious errors in propagating type hints. example
- Infer type in a conditional type is now allowed to be underconstrained. When the true branch is taken, this underconstrained infer type will be pinned to the upper bound. example
- Add
Enum
andEnumValue
to$NotNullOrVoid
- previously there was no supertype for all enum values or enums.
IDE:
- We now show jsdoc information on component props with component syntax.
v0.233.0
Likely to cause new Flow errors:
- Flow will now error on invalid type applications at the declaration site, if the type application does not use another generic type from an outer scope. example
- We fixed a bug where we incorrectly unwrapped the opaque type to the underlying representation in refinements
- Predicate functions (%checks) can no longer be recursive
- Fixed subtyping of indexers in instances/interfaces
Notable bug fixes:
- We fixed some spurious errors regarding opaque type refinements. example
- We made a change to method-unbinding errors so that it no longer errors when in an any/mixed context. This allows us to better support jest
- We fixed an issue where explicitly supplied JSX type arguments were ignored
- We fixed bigint Flow Enums that do not explicitly speicy
of bigint
during parsing. We were previously not correctly inferring that this was a bigint enum. - flow.org/try now supports go-to-definition, autocomplete, and signature help
Parser:
- Previously Flow outputs
ReadOnlyTypeAnnotation
in parser output for annotations likereadonly string[]
. Now we output it asTypeOperator
with"operator": "readonly"
IDE:
- Fix printer output of casting syntax when LHS of
as
oras const
has low precedence
Library Definitions:
- We migrated the built-in React library definitions to use component and hook syntax for various React-provided APIs. Look out for a blog post on our medium account for more details and see the React section in our docs
v0.232.0
Likely to cause new Flow errors:
- Support for
$Compose
and$ComposeReverse
types are removed. We recommend to use overloads to approximate their behavior instead. e.g.
declare export function compose(): <T>(a: T) => T;
declare export function compose<F: (...$ReadOnlyArray<empty>) => mixed>(
f: F,
): F;
declare export function compose<A, T: $ReadOnlyArray<any>, R>(
f1: (a: A) => R,
f2: (...T) => A,
): (...T) => R;
declare export function compose<A, B, T: $ReadOnlyArray<any>, R>(
f1: (b: B) => R,
f2: (a: A) => B,
f3: (...T) => A,
): (...T) => R;
declare export function compose<A, B, C, T: $ReadOnlyArray<any>, R>(
f1: (c: C) => R,
f2: (b: B) => C,
f3: (a: A) => B,
f4: (...T) => A,
): (...T) => R;
declare export function compose<R>(
f1: (b: any) => R,
...funcs: $ReadOnlyArray<(...$ReadOnlyArray<empty>) => mixed>
): (...$ReadOnlyArray<any>) => R;
declare export function compose<R>(
...funcs: $ReadOnlyArray<(...$ReadOnlyArray<empty>) => mixed>
): (...$ReadOnlyArray<any>) => R;
- You might see more errors around type application. example
- Fix subtyping of indexers in instances/interfaces. example
New Features:
- Updated the
isValid
Flow Enums method to use a type guard, allowing it to refine its input to the enum type in a conditional context.
E.g.
enum Status {Active, Off}
const s = "Active";
if (Status.isValid(s)) {
s as Status; // Should work
}
export type Foo = ...
andexport interface Bar {...}
statements are now allowed indeclare module
anddeclare namespace
bodies.- We added a new codemod
flow codemod remove-unnecessary-react-import
which can help remove unnecessary react imports underreact.runtime=automatic
Notable bug fixes:
- Fixed issue when explicitly supplied JSX type arguments are ignored
- Fixed code action output of casting syntax when LHS of
as
oras const
has low precedence
Library Definitions: