Adds static typing to JavaScript to improve developer productivity and code quality.
MIT License
Bot releases are visible (Hide)
Published by facebook-github-bot 5 months ago
Likely to cause new Flow errors:
New Features:
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:
[...[]] as []
now works.React.ElementConfig/Props
when passed in a component syntax component (e.g. try-Flow)Published by facebook-github-bot 6 months ago
Likely to cause new Flow errors:
super
with a props object. example
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.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.isValid
Flow Enums method, reverting back to behavior from before v0.232.$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
.--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:
mixed
(such as $NonMaybeType<mixed>
). (try-Flow examples)Misc:
export type *
(ExportAllDeclaration) nodes with flow-remove-types
(thanks @jbroma!)Parser:
bigint
property to match ESTree spec. Numeric separators are removed (_
), and should contain only decimal digits.IDE:
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.$await
in the libdef. If you are depending on it like typeof $await
, you can replace it with <T>(Promise<T> | T) => T
.Likely to cause new Flow errors (copied from 0.235.0 release notes):
Misc:
flow ast
will now parse component syntax rather than reject it. You can pass --no-component-syntax
to get the old behavior (D56501290 samzhou19815)Published by facebook-github-bot 6 months ago
Likely to cause new Flow errors:
type T = T
or type Foo = typeof foo; const foo: Foo = ...
. In addition to this, you might see some errors being moved around.any
.New Features:
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>
.Enum<>
, which represents all Flow Enums (this is a complement to the new EnumValue
type). You can constrain the enums to ones which have a particular enum value, e.g. Enum<>
is the same as Enum<EnumValue<>>
, and the type of all enums with string representation types is Enum<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.===
comparison of abstract Flow Enums as well as Enums themselves with the same ID..valueOf()
, e.g. enum E {A, B}; const s: string = E.A.valueOf()
.Notable bug fixes:
Enum
and EnumValue
to $NotNullOrVoid
- previously there was no supertype for all enum values or enums.IDE:
Published by facebook-github-bot 7 months ago
Likely to cause new Flow errors:
Notable bug fixes:
of bigint
during parsing. We were previously not correctly inferring that this was a bigint enum.Parser:
ReadOnlyTypeAnnotation
in parser output for annotations like readonly string[]
. Now we output it as TypeOperator
with "operator": "readonly"
IDE:
as
or as const
has low precedenceLibrary Definitions:
Published by facebook-github-bot 7 months ago
Likely to cause new Flow errors:
$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;
New Features:
isValid
Flow Enums method to use a type guard, allowing it to refine its input to the enum type in a conditional context.enum Status {Active, Off}
const s = "Active";
if (Status.isValid(s)) {
s as Status; // Should work
}
export type Foo = ...
and export interface Bar {...}
statements are now allowed in declare module
and declare namespace
bodies.flow codemod remove-unnecessary-react-import
which can help remove unnecessary react imports under react.runtime=automatic
Notable bug fixes:
as
or as const
has low precedenceLibrary Definitions:
Published by facebook-github-bot 7 months ago
Likely to cause new Flow errors:
New Features:
method-unbinding
errors with indexed access types.relay_integration.esmodules
option. When this option, along with relay_integration
, is enabled, Flow will treat graphql
fragments/queries/etc. as import default
rather than require
. Use this when you ouput ESM from Relay's codegen (e.g. eagerEsModules
).Notable bug fixes:
AsyncGenerator<T, void, void>
type is expected (e.g. try-Flow)IDE:
AUTO332
appeared in the result of string literal type completion.Library Definitions:
FileSystem
APIs (thanks @ZelJin).StorageManager
class (thanks @ZelJin).checkPropTypes
, DOM
, createClass
, ConcurrentMode
from react
module.import React from 'react'
, they can also be used without imports, e.g. type N = React.Node
.Likely to cause new Flow errors:
// 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';
// 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
Array = 3; $ReadOnlyArray = 2;
Now the latter is banned.value-as-type
or recursive-definition
errors will no longer affect which branch to take in overload resolution.New Features:
type T = typeof foo<string>
. This syntax is supported in prettier since v3.1. If you previously enabled the flag typeof_with_type_arguments=true
, you need to remove it.<Foo<string, _, number >propA='d' />
. Note that some type arguments can be inferred using the _
syntax.NoInfer
intrinsic that will be available in TypeScript 5.4.experimental.ts_syntax=true
, Flow will
$ReadOnly<[...]>
and $ReadOnlyArray<...>
without error.$Keys
without error. Note that there are behavior differences between $Keys<>
and keyof
right now (flow, TS), so use it with caution.unknown
never
and undefined
into Flow equivalent mixed
empty
and void
without error.readonly
in
out
, in out
without error.Misc:
experimental.ts_syntax
is now always on in https://flow.org/try.Published by facebook-github-bot 8 months ago
Misc:
experimental.blocking_worker_communication=false
.Published by facebook-github-bot 8 months ago
Misc:
Published by facebook-github-bot 8 months ago
Likely to cause new Flow errors:
invalid-recursive-exported-annotation
will now have error code of recursive-definition
.value-as-type
errors. (example).declare module
will no longer cause parse errors. Instead, they will be errored on during type checking.declare export type
and declare export interface
statements in toplevel are no longer parser errors. Instead, they will now be errored during type checking.toplevel-library-import
errors and unsupported-statement-in-lib
errors will all have unsupported-syntax
error code now.New Features:
experimental.ts_syntax
flag that you can set to true
. 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 using extends
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:
declare module
, all the values will be auto-exported if we cannot decide whether the module is in CJS or ESM. However, support for declare const
and declare let
was missing. This has now been fixed.Misc:
both
the default value for the .flowconfig casting_syntax
option, if not supplied.Published by facebook-github-bot 9 months ago
Likely to cause new Flow errors:
React.cloneElement
with polymorphic components. Eg. try-Flow. Note that React.cloneElement is deprecated
declare module
is no longer a parser error, but a type checking errordeclare module
is now explicitly banned in nested scope and outside of library definition files. It already does nothing under those contexts.New Features:
prop = (foo: string): number => 3
.Notable bug fixes:
flow check
to always return 0 errors, when some parts of temporary directory is a symlink.React$Element
. (e.g. try-Flow)export function f(a) {}
, we now say "Missing type annotation at identifier" instead of "Missing type annotation at array pattern".Parser:
declare namespace Foo {...}
statements. The body of the declare namespace statement shares the same restrictions of declare module
.declare module
are no longer parse errors. They are now type checker errors.Published by facebook-github-bot 9 months ago
Likely to cause new Flow errors:
type T = T
as empty
, instead of any
. (e.g. try-Flow)..call()
on polymorphic functions where the return type is under-constrained (e.g. try-Flow). To fix add an annotation to the return result.Parser:
Library Definitions:
Array.from
overloads. It might cause some error locations and codes to change.window.navigator.storage
(thanks @ZelJin).Published by facebook-github-bot 10 months ago
Likely to cause new Flow errors:
IDE:
Notable bug fixes:
DOMStringList
as iterable, so that it works with Array.from(...)
(thanks @bobrovnikov)Published by facebook-github-bot 10 months ago
Notable bug fixes:
Published by facebook-github-bot 10 months ago
Notable bug fixes:
Published by facebook-github-bot 10 months ago
Likely to cause new Flow errors:
%checks
is now deprecated. It will still work as before (for now), but if you enable the deprecated-type
Flow lint, you will see additional errors. Instead, use type guards.$Call
, $ObjMap
, $ObjMapi
, $ObjMapConst
are now deprecated. They will still work as before (for now), but if you enable the deprecated-type
Flow lint, you will see additional errors. Since Flow 0.209, you can now use builtin types like Parameters
, ReturnType
, Pick
, Omit
to easily extract and transform types. For more advanced use cases, you can read the docs of conditional type and mapped type to understand how to write it in equivalent ways.number
keysnumber
keysNew Features:
const obj = {1: true, 2: false}
Notable bug fixes:
Array.from
with string input and also mapping function, e.g. Array.from('str', x => x.length)
IDE:
Library Definitions:
crypto
object, crypto.getRandomValues
, and crypto.randomUUID
StatelessFunctionalComponent
type from the 'react' module and the React$StatelessFunctionalComponent
type. The name might give an incorrect assumption that Flow can actually check that a function component doesn't use stateful hooks or can be called directly. If you have code that still uses this type, we recommend you use the React.AbstractComponent
type, since it forces you to not make any assumption of what kind of React component you are dealing with.Published by facebook-github-bot 11 months ago
Before Flow 0.223, the autoimport system uses the filename as a hint of the name for default export. e.g. if the filename is foo.react.js
or foo.js
, regardless of whether the default export in that file has a name or not, or even the default name is bar
, autoimport will always import it as import foo from 'foo'
.
However, in the new system starting from Flow 0.223, we will use the name of the default export as a stronger hint. In a lot of files that just give a default export a random generic name, they are relying on the old system to get reasonable auto imports.
It's not practical to update every Flow codebase to avoid the UX regression, so now auto-import will provide both options.
Published by facebook-github-bot 11 months ago
Notable bug fixes:
any
. (Example: Issue #9107)IDE:
Misc:
incremental_error_collation
flowconfig option is not recognized anymore.Library Definitions:
status
global from dom.jsReact
module. You should always import react with lowercase like require('react')
or import React from 'react'