Releases: facebook/flow
Releases · facebook/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:
v0.231.0
Likely to cause new Flow errors:
- Fixed subtyping of inline interfaces, e.g. try-flow.
New Features:
- No longer trigger
method-unbinding
errors with indexed access types. - Add
relay_integration.esmodules
option. When this option, along withrelay_integration
, is enabled, Flow will treatgraphql
fragments/queries/etc. asimport default
rather thanrequire
. Use this when you ouput ESM from Relay's codegen (e.g.eagerEsModules
).
Notable bug fixes:
- Don't error when returning an array, map, etc when an
AsyncGenerator<T, void, void>
type is expected (e.g. try-Flow)
IDE:
- Fixed a bug where
AUTO332
appeared in the result of string literal type completion.
Library Definitions:
- Added definitions for
FileSystem
APIs (thanks @ZelJin). - Added constructor to the
StorageManager
class (thanks @ZelJin). - Removed
checkPropTypes
,DOM
,createClass
,ConcurrentMode
fromreact
module. - Types in react module can now also be used when React is default imported like
import React from 'react'
, they can also be used without imports, e.g.type N = React.Node
.
v0.230.0
Likely to cause new Flow errors:
- We now put value exports and type exports into two different namespaces. It means that we will now consistently error on places where you try to import, re-export, or use a imported type as a value. This change also makes certain patterns that happen to work in the past no longer work, e.g.
// a.js
export type Foo = string;
// b.js
const A = require('./a');
module.exports = {...A};
// c.js
// previously allowed, no longer allowed
import type {Foo} from './b';
- We have allowed function parameters to refer to each other for a while now. However, we didn't implement the analysis correctly for exported functions, which causes inconsistent behaviors. This is now fixed e.g.
// a.js
// we incorrectly resolve x to refer to
// be external to the function params,
// which is a global in this case
export function foo(x: string, y: typeof x) {}
// b.js
import {foo} from './a';
foo("", 3); // no error before, errors now
- Previously, we allowed assignment to any globals, regardless of whether it's a type or value. Therefore, both were allowed in
Array = 3; $ReadOnlyArray = 2;
Now the latter is banned. - Flow now consistently bans referring a type-only global as value
- Some bad annotations that cause
value-as-type
orrecursive-definition
errors will no longer affect which branch to take in overload resolution.
New Features:
- Flow now supports typeof with type arguments
type T = typeof foo<string>
. This syntax is supported in prettier since v3.1. If you previously enabled the flagtypeof_with_type_arguments=true
, you need to remove it. - Flow now supports explicit type arguments on JSX. e.g.
<Foo<string, _, number >propA='d' />
. Note that some type arguments can be inferred using the_
syntax. - Flow now supports the same
NoInfer
intrinsic that will be available in TypeScript 5.4. - Under
experimental.ts_syntax=true
, Flow will- Automatically translate TypeScript's readonly on tuple and array types into Flow equivalent
$ReadOnly<[...]>
and$ReadOnlyArray<...>
without error. - Automatically translate TypeScript's keyof into Flow equivalent
$Keys
without error. Note that there are behavior differences between$Keys<>
andkeyof
right now (flow, TS), so use it with caution. - Automatically translate TypeScript's
unknown
never
andundefined
into Flow equivalentmixed
empty
andvoid
without error. - Support TypeScript's variance annotation
readonly
in
out
,in out
without error.
- Automatically translate TypeScript's readonly on tuple and array types into Flow equivalent
Misc:
experimental.ts_syntax
is now always on in https://flow.org/try.
v0.229.2
Misc:
- Fixed a potential crash under the experimental flag
experimental.blocking_worker_communication=false
.
v0.229.1
Misc:
- Bug fixes in preparation of new feature rollout
v0.229.0
Likely to cause new Flow errors:
invalid-recursive-exported-annotation
will now have error code ofrecursive-definition
.- Previously we would emit confusing errors when you try to use a value that has union types as a type. Now it will consistently emit
value-as-type
errors. (example). - Unsupported statements like loops within
declare module
will no longer cause parse errors. Instead, they will be errored on during type checking. declare export type
anddeclare export interface
statements in toplevel are no longer parser errors. Instead, they will now be errored during type checking.- Previous
toplevel-library-import
errors andunsupported-statement-in-lib
errors will all haveunsupported-syntax
error code now.
New Features:
- We introduced
experimental.ts_syntax
flag that you can set totrue
. When this flag is on, Flow will no longer complain about certain TypeScript syntax, and will automatically turn them into the closest Flow equivalent types. Initially, we support the following:Readonly
,ReadonlyArray
,ReadonlyMap
,ReadonlySet
,NonNullable
, and usingextends
to specify type parameter bounds. In the future, more kinds of types that we currently parse but error on might be added. (e.g. keyof). Please note that the support here is best effort. We make no guarantee that these types have the same semantics as those in TypeScript 100% of the time, but for common cases, it might be good enough for you.
Notable bug fixes:
- We now allow the use of saved state for glean indexer, if saved state is enabled in flowoconfig or CLI arguments.
- Improved the way we compute contextual hints for spread arguments of calls (e.g. try-Flow).
- In
declare module
, all the values will be auto-exported if we cannot decide whether the module is in CJS or ESM. However, support fordeclare const
anddeclare let
was missing. This has now been fixed.
Misc:
- Make
both
the default value for the .flowconfigcasting_syntax
option, if not supplied.