Adds static typing to JavaScript to improve developer productivity and code quality.
MIT License
Bot releases are visible (Hide)
Likely to cause new Flow errors:
New Features:
['s']
and ['s', 1]
are both valid values for [foo: string, bar?: number]
.exact_by_default=true
is now the default value if the option is omitted from the .flowconfig
. Read this blog post for more details.Notable bug fixes:
null
and void
from the inferred type of the parameter. This removes spurious errors like this.prop-missing
errors might be removed. Example here
Misc:
module.system.haste.module_ref_prefix_LEGACY_INTEROP
in the config to allow migration from the automatic_require_default
flag and to ES module syntax.Parser:
(A | B)[]
.Published by facebook-github-bot over 1 year ago
Local Type Inference:
Likely to cause new Flow errors:
null
, we use all the assignments to the variables as its initial type. We now no longer consider assignments from a child generic function. As a result, you might get new invalid-declaration
errors. Example
$Partial
will now preserve the variance of the input object type's properties. For example, if the the input was a read-only object, now that output will also be a read-only object (with optional properties).string
and symbol
are no longer subtypes of an interfacewith
statements in non-strict mode. It was already a syntax error in strict mode.New Features:
/**
use_mixed_in_catch_variables
config option that makes catch
variables default to mixed
instead of any
$Partial
utility type to Partial
. $Partial
will continue working as an alias for at least one more version - use that period of time to codemod it to Partial
.Required
utility type. It does the opposite of Partial
: it makes optional properties required in object types.Object.values
on a Flow Enum, to point the user to using .members()
number
and boolean
primitives as a subtype of an interfaceNotable bug fixes:
underconstrained-implicit-instantiation
errors that were otherwise impossible to fix.$Keys
$Shape
utility type to Partial
. It is possible that this will create type errors that you will have to resolve.$Partial
to Partial
Misc:
unused-promise-in-async-scope
and unused-promise-in-sync-scope
. They can be enabled with unused-promise
.--evaluate-type-destructors
flag from type-at-pos
commandflow save-state --scm
flag to ease creation of SCM-aware saved statesParser:
infer
a reserved word in typesPublished by facebook-github-bot over 1 year ago
Notable bug fixes:
We fixed a bug that causes spurious Array is not an array
errors in try-flow. Example
Published by facebook-github-bot over 1 year ago
Likely to cause new Flow errors:
missing-local-annot
errors on return type annotation positions.any
type. Instead, they will be properly contextually typed. e.g. try Flow example.exact_by_default
option is now required to be set in the [options]
section of the .flowconfig
. Add either exact_by_default=true
or exact_by_default=false
to your [options]
section. Previously the absence of the option was equivalent to exact_by_default=false
. In the future, we will make the absence of the option equivalent to exact_by_default=true
. Read more about the option here: https://flow.org/en/docs/config/options/#toc-exact-by-default-boolean. To create a valid new .flowconfig
, use flow init
.missing-local-annot
error under LTI. e.g. try Flow example
this
type of exported classes' methods are no longer unsoundly typed as any
. As a result, more underconstrained implicit instantiation errors might show up in LTI.New Features:
flow autofix missing-local-annot
command that will try to add annotations to autofix all missing-local-annot
errors in a given file.missing-local-annot
errors where we can locally infer a type. Previously, this kind of autofix is only provided for unannotated parameters.unused-promise-in-sync-scope
lint which will detect unused promises in sync scopes (like unused-promise-in-async-scope
does for async scopes). Enabling unused-promise
will enable both of these rules. The individual rules will be removed in a future release.// @flow strict
, // @jsx custom_jsx_fun
) are now supported in try-flow.IDE:
$FlowFixMe
comments.Notable bug fixes:
missing-local-annot
when there is a proper typing context in super
call. e.g. super(x => x)
will now pass type checking under LTI if the super constructor call expects such function.$ReadOnly
will no longer shadow your local definitions with the same name.Parser:
function
as an alias to Function
, and don't allow function
as a type name in general. (closes issue #9000).Published by facebook-github-bot over 1 year ago
Notable bug fixes:
Published by facebook-github-bot over 1 year ago
Likely to cause new Flow errors:
declare function compose<T>(
fns:...$ReadOnlyArray<T=>T>,
): T;
getTime()
.Array<empty>
under LTI. e.g. Array.from(nullableStringArray ?? [])
. As a result, previously hidden errors might be revealed.missing-local-annot
error might be shown in cases when we cannot resolve overload. Example
declare function id<T>(T): T;
id([(item) => 1]); // now errors
New Features:
declare let
and declare const
. These work like declare var
, but follow the rules of let
and const
respectively.Notable bug fixes:
$Compose
now works under LTI mode.illegal-this
error when a this annotation is used in contextual typing.function f({a: b}): boolean %checks { return typeof b === 'string'; }
. Instead, you will only get error on this unsupported syntax.String.raw
. (Closes #7580. Fixes #5705. Fixes #2616.)underconstrained-implicit-instantiation
errors, when we decide that using type parameter default or bound won't cause downstream errors.Misc:
Parser:
Published by facebook-github-bot over 1 year ago
Notable bug fixes:
Parser:
await
in async formal parameters (including a regression in 0.198.0)Published by facebook-github-bot almost 2 years ago
Published by facebook-github-bot almost 2 years ago
Likely to cause new Flow errors:
unsafe-arithmetic
.keyof
, undefined
, never
, unknown
, and readonly
are now reserved types. If you have a user-defined types of these names, rename them to something else.New Features:
keyof
type operator, recommending $Keys<...>
instead.undefined
type, recommending void
instead.never
type, recommending empty
instead.unknown
type, recommending mixed
instead.readonly
applied to tuple and array type syntax.in
/out
/in out
variance annotations.as
, as const
, and satisfies
cast expressions.flow codemod annotate-implicit-instantiations --include-lti --ignore-suppressed --write .
Notable bug fixes:
IDE:
Object.prototype
are no longer included in autocomplete results.Parser:
for await (async of ...)
(regressed in 0.197.0)for (let in x)
in non-strict modestatic
await
as a parameter in an async arrow functionexport { ReservedWord as ... }
export * as ReservedWord from ...
, which is now allowed&&
and ||
as tokens when parsing types to improve error messagestypeof
type argument as a value, not a type, as it is a valueLibrary Definitions:
Element.getAttributeNames(): Array<string>
Published by facebook-github-bot almost 2 years ago
Local Type Inference:
We are releasing a new inference mode called local type inference. You can enable this new mode in your codebase by adding inference_mode=lti
to the [options]
section in the flowconfig. We will describe more details on this inference mode in an upcoming blog post.
Likely to cause new Flow errors:
bool
is a deprecated alias for boolean
. Added a deprecated-type-bool
lint and flow fix --error-codes deprecated-type
codemod to help migrate to boolean
. This lint is also included in the deprecated-type
lint; if deprecated-type
is enabled, you can opt out with deprecated-type-bool=off
New Features:
$ReadOnly
utility makes tuples read-only. E.g. $ReadOnly<[string, number]>
is the same as [+a: string, +b: number]
.type T = [+foo: number, +bar: string]
creates a read-only tuple.mixed
or any
as an annotation to a catch
parameter (but not anything else)Notable bug fixes:
Misc:
any
(instead of V$n
) in hover types.Parser:
symbol
is now a reserved typefor (async of [])
is now a parse errorLibrary Definitions:
AbortController
and AbortSignal
signaturesReactSetStateFunction
type introduced in the last release.Published by facebook-github-bot almost 2 years ago
Published by facebook-github-bot almost 2 years ago
🎁 This is (hopefully) our last release of the year. Happy holidays! 🎁
saved_state.allow_reinit
optionPublished by facebook-github-bot almost 2 years ago
Published by facebook-github-bot almost 2 years ago
Likely to cause new Flow errors:
mixed
, type the result of Object.values
and Object.entries
on a dictionary to be the dictionary values, and Object.entries
keys to behave like Object.keys
. Closes #2174, #2221, #4771, #4997, #5838.Object.values
and Object.entries
.name
and length
property are now not writable.Object.keys
, $Values
, and $Keys
on interfaces with indexers.$Subtype
and $SuperType
utilities.deprecated-utility
Flow lint.New Features:
export default (3 + 3 : number)
can now just be export default 3 + 3;
).Notable bug fixes:
any
or number
.1
or true
to be truthy. Before, anything other than 0
and false
was considered truthy.Misc:
Library Definitions:
ReactSetStateFunction
type alias in react. This is the type of setVal
in const [val, setVal] = React.useState(...)
.Published by facebook-github-bot almost 2 years ago
Misc:
--experimental.run-post-inference-implicit-instantiation true/false
CLI flagPublished by facebook-github-bot almost 2 years ago
Misc:
Published by facebook-github-bot almost 2 years ago
unused-promise-in-async-scope
lint which will insert void
.symbol
and bigint
to $NotNullOrVoid
findLast
to Array
definitionPublished by facebook-github-bot almost 2 years ago
Likely to cause new Flow errors:
empty
will now properly error, e.g. (E.A: empty)
.New Features:
unused-promise-in-async-scope
lint which will insert await
.<
, >
, <=
, >=
), update (++
, --
) and arithmetic operators (+
, -
, ~
, *
) to be used with bigints.sketchy-null-bigint
lint to match the behavior of the other sketchy-null-*
lints for bigints.declare enum
and declare export enum
. Keep in mind that users need to have enabled Flow Enums if you wish to create library definitions that use them.Parser:
flow_parser
OPAM package. Some modules in src/parser/
like Comment_utils
are newly available.flow_parser.js
by roughly 25%, to 768kb.declare opaque type
was parsed as an OpaqueType
when interned comments are disabled.Published by facebook-github-bot almost 2 years ago
New Features:
Notable bug fixes:
module.system.node.root_relative_dirname
setting when doing so. Also, scoped package names are now supported in the Haste module resolver.Misc:
module.system=haste
, importing packages in node_modules
folders now obeys Node's resolution algorithm, rather than being able to be required from anywhere in the project.Library Definitions:
Published by facebook-github-bot almost 2 years ago
Notable changes:
exact_empty_objects
flag and the annotate_empty_object
codemod are now deleted, See https://medium.com/flow-type/improved-handling-of-the-empty-object-in-flow-ead91887e40c for more details.inference_mode=experimental.lti
to your flowconfig.Likely to cause new Flow errors:
cannot-resolve-name
errors now are emitted for every use of an undefined variable, not just the first.New Features:
unused-promise-in-async-scope
in the lint section of your flowconfig.Misc:
annotate-use-state
and annotate-use-callback
codemod commands have been merged into annotate-react-hooks
4Library Definitions:
interface {}