Adds static typing to JavaScript to improve developer productivity and code quality.
MIT License
Bot releases are visible (Hide)
Published by facebook-github-bot almost 2 years ago
Likely to cause new Flow errors:
exact_empty_objects
option is now enabled by default. Details about this change and how to update your codebase are covered on our blog.typeof X
type annotation now respects the initialization state of X
: if X
hasn't been declared it will be an error to get its type.Notable changes:
enforce_local_inference_annotations
config option was removed. To migrate your codebase, run the following codemod to add the required annotations: flow codemod annotate-lti
. More details on the changes are explained in the Requiring More Annotations to Functions and Classes in Flow blog post.Published by facebook-github-bot about 2 years ago
hg update
Published by facebook-github-bot about 2 years ago
Note:
Due to large number of likely new Flow errors that will be introduced in the next release, we decided to create an extra release to ease the upgrade process.
We announced in the recent blog post that we would remove the enforce_local_inference_annotations
option in flowconfigs, as it became the default in v0.189.0. This change will be delayed to v0.191.0 instead.
Likely to cause new Flow errors:
extends
clauses in class definitions are either variables, casts, or member expressions, rather than allowing arbitrary expressions.any
and type applications like Promise<T>
, which may cause new downstream errors to be discovered.Notable bug fixes:
Published by facebook-github-bot about 2 years ago
Likely to cause new Flow errors:
enforce_local_inference_annotations
is now on by default. To migrate your codebase run the following codemod to add the required annotations: flow codemod annotate-lti
. More details on the changes are explained in the Requiring More Annotations to Functions and Classes in Flow blog post.New Features:
this
is not typed explicitly.Notable bug fixes:
object-this-reference
errors. Previously these errors were missing when the object is an argument of Object.freeze()
, Object.defineProperties()
or Object.create()
.Library Definitions:
fs.readFile
type definition when the encoding
config option is supplied.Published by facebook-github-bot about 2 years ago
Bug fixes:
Performance:
Published by facebook-github-bot about 2 years ago
Bug fixes:
Misc:
flow codemod annotate-lti
to flow codemod annotate-functions-and-classes
to clarify that this is not the only codemod necessary for enabling LTI eventually.Likely to cause new Flow errors:
Previously we supported a weird JS runtime rule for constructor returns when you call new SomeClass
:
new SomeClass
.This is confusing, and we dropped support for this feature in this release. Now we enforce that all class constructors must return void.
Fixed a bug preventing refinements from being invalidated in inline &&
expressions: examples like typeof x === 'number' && reassignXToString() && (x: number)
were passing even if reassignXToString()
assigned a a string value to x
.
New Features:
flow codemod annotate-lti
is now provided to help prepare your codebase to enable the enforce_local_inference_annotations=true
flag. In order to eventually enable local type inference, we will require additional annotations in places we can't contextually type your code. You can enable the annotation enforcement now with enforce_local_inference_annotations=true
in flowconfig. This flag enables the behaviors of all the following experimental flags, which will be deleted in the next release:experimental.enforce_local_inference_annotations=true
experimental.enforce_this_annotations=true
experimental.enforce_class_annotations=true
To migrate your codebase, you can run the following codemod to prepare your codebase for the new requirement: flow codemod annotate-lti
. Check out an upcoming blog post for more details.
Misc:
file_watcher.watchman.survive_restarts
flowconfig option, which was deprecated in 0.158.0. We will always try to survive Watchman restarts.experimental.refactor
flowconfig option. It has been true
by default since v0.158.0.Library Definitions:
fs.promises.readdir()
to reflect the possibility of passing withFileTypes: true
and receiving an array of Dirent
objectsPublished by facebook-github-bot about 2 years ago
Published by facebook-github-bot about 2 years ago
Likely to cause new Flow errors:
@jsx Foo.bar
) will no longer be incorrectly considered as unreachable. This might uncover previously hidden errors.New Features:
foo|Baz
(cursor at |
) and choose fooBar
, you'll now get fooBarBaz
instead of fooBar
. In VS Code, you can press shift-enter to replace instead of insert.Bug fixes:
declare module
exports (D38977152 mroch)flow get-def --json
to write {"error": message}
to stdout on error, instead of writing non-JSON to stderrLibrary Definitions:
import.meta
. They are typed as mixed
Published by facebook-github-bot about 2 years ago
Notable breaking changes:
inference_mode=classic
has been removed. The default is now inference_mode=constrain_writes
. Please refer to the blog post for migration paths. Additionally we have removed all codemod commands that depend on the classic inference mode. This includes the annotate-declarations
, rename-redefinitions
and annotate-escaped-generics
codemods.Likely to cause new Flow errors:
this
in object getters and setters are now banned. Referencing this
in object methods are already banned, and this change makes Flow's behavior more consistent.Notable bug fixes:
Library Definitions:
PerformanceServerTiming
definition and the serverTiming
attribute to PerformanceResourceTiming
.Published by facebook-github-bot about 2 years ago
New Features:
@jsxRuntime
pragma in the top docblock of each JS module. Allowed values are classic
and automatic
.Published by facebook-github-bot about 2 years ago
Misc:
autoimports_ranked_by_usage=true
)Published by facebook-github-bot about 2 years ago
Likely to cause new Flow errors:
x = some expression containing x
have a type that's effectively any
. If you turned on inference_mode=constrain_writes
since the last release, there will be new errors.esproposal_export_star_as
as an option and make this the default as it made it into the JS standard in 2018.value-as-type
errors might be emitted, as a result of existing importing errors.New Features:
inference_mode=constrain_writes
will be the default. inference_mode=classic
, which is the current default, will be removed in the next release. Please refer to the blog post for migration paths.Misc:
Library Definitions:
.x
and .y
properties to DOMRect. (Thanks @pmer)Published by facebook-github-bot about 2 years ago
Upcoming Breaking Changes:
New Inference Mode:
We are releasing a new inference mode that marks significant progress on our way to local type inference. You can enable this new mode in your codebase by adding inference_mode=constrain_writes
to the [options]
section in the flowconfig.
We will make inference_mode
default to constrain_writes
in v0.185, and remove the classic
option in v0.186. To migrate your codebase, you can run the following codemods to prepare your codebase for the new inference mode:
flow codemod rename-redefinitions
flow codemod annotate-declarations
We will describe more details on this inference mode in an upcoming blog post.
Additional Annotation Requirements:
In order to eventually enable local type inference, we will require additional annotations in places we can't contextually type your code. You can enable the annotation enforcement now with the following flags in flowconfig:
experimental.enforce_local_inference_annotations=true
experimental.enforce_this_annotations=true
experimental.enforce_class_annotations=true
To migrate your codebase, you can run the following codemod to prepare your codebase for the new requirement: flow codemod annotate-lti-experimental
Likely to cause new Flow errors:
Object.create
now results in a sealed object. Arbitrary properties can no longer be read/written from/to it. You can use the __proto__
property in object annotations to create an annotation if you need to.Notable bug fixes:
function emit(...args: [{+bar: string}]): void {}
emit({ bar: "" }); // no longer emits incompatible-variance
flow-upgrade
:
exact_empty_objects
flowconfig optionLibrary Definitions:
Published by facebook-github-bot about 2 years ago
Published by facebook-github-bot over 2 years ago
Likely to cause new Flow errors:
New Features:
exact_empty_objects
is enabled.useState
codemod to support null
/undefined
/empty-array arguments.Notable bug fixes:
Parser:
Library Definitions:
fs.readdir
and fs.readdirSync
to allow better overload resolution.String.prototype.replaceAll()
(Thanks @dav-s).Published by facebook-github-bot over 2 years ago
Likely to cause new Flow errors:
var
re-declarations are now banned. You should use let
or const
instead.Notable bug fixes:
Misc:
Published by facebook-github-bot over 2 years ago
--saved-state-verify
flag to check that a saved state matches what is expected to be on disk.Published by facebook-github-bot over 2 years ago
Notable bug fixes:
Published by facebook-github-bot over 2 years ago
Notable bug fixes:
Parser:
Library Definitions:
v8
module