Likely to cause new Flow errors:
- Disallow duplicate member names in classes.
- Error if an interface is imported as a value.
- The
experimental.new_merge
option becomestrue
by default. This is an internal change in the way file signatures are computed, but may cause new[invalid-exported-annotation]
errors when a file exports types that include certain kinds of complex operations, such as projections over complex utility types like$ObjMap
. These errors can be fixed by replacing these complex types with simpler ones. In certain cases, the newly added$KeyMirror
and$ObjMapConst
types (that are exempt of this restriction) can be used instead.
Notable bug fixes:
- Fix Watchman file watcher on Windows when an include path doesn't exist.
- Fix a parse error when a newline appears after a class method definition's name.
Parser:
- Add support for parsing logical assignment operators (thanks @strub).
- Fix compliance with estree:
export * as x from 'y'
is now anExportAllDeclaration
with anexported
key. - Permanently enable parsing of nullish coalescing, and remove the
esproposal_nullish_coalescing
option. - Permanently enable parsing of optional chaining, and remove the
esproposal_optional_chaining
option. - Permanently enable parsing of class static fields, and remove the
esproposal_class_static_fields
option. - Permanently enable parsing of class instance fields, and remove the
esproposal_class_instance_fields
option.
Library Definitions:
- Make some
options
parameters in node'sfsPromises
optional.
Another light release due to the new year. Changes are mainly internal -- refactoring or progress towards future features.
Notable breaking changes:
- Disallow duplicate member names in classes
This release is light on changes due to the holidays. Happy New Year!
- Improve performance
Notable bug fixes:
- Improve performance of IDE requests when using lazy mode and saved state
- Improve performance of checking union types by optimizing enums more aggressively
Notable bug fixes:
- Fix crash when moving a module introduced in v0.167.0
Notable bug fixes:
- Error on invalid
@flow
modes
Misc:
- Remove the
--profile
,--json
and--pretty
flags fromflow force-recheck
- Reduce usage of shared heap space
Library Definitions:
- Add support for Node inspector
- Improve Document definition
- Add document.contentType
- Add 'navigate' as valid request ModeType (Thanks @comp615)
- Fix a crash introduced in 0.166.0
- Improve recheck performance on large projects
- No longer support
flow check-contents
on non-Flow files by default; pass--all
to force it. - No longer attempt to provide LSP documentHighlight on non-Flow files.
- Remove legacy "weak" mode. The
--weak
CLI flag andweak=true
flowconfig option have been removed.
Notable bug fixes:
- Improve performance of signature help
- Fix a bug that caused rechecks to be unnecessarily invalidated and restarted
Likely to cause new Flow errors:
- The Flow parser now requires that variables declared using the
declare var
syntax be annotated with a type.declare var x;
is now illegal.
Notable bug fixes:
- No longer attempt to provide autocomplete or
flow autocomplete
on non-Flow files. - Fix a crash when deleting a file in lazy mode
- Fix a bug that prevented some code actions from adding type imports for
export default class
definitions
New Features:
exports
/module.exports
can no longer be read from in a module (e.g.exports.foo
) to eliminate this usage of unsealed objects - you can refactor your code to directly referencefoo
instead, or just use ES modules (e.g.export const foo = ...
)- Improved autocomplete for the targets of
typeof
type annotations. - Support for finding references and renaming has been removed. While these features often worked well, they also caused extremely bad performance and crashes. We hope to reimplement these features as soon as we can.
- When displaying types, always use indexed access types for
$ElementType
and$PropertyType
utilities. - Remove
indexed_access
option, it's always enabled now (was on by default before if the option was omitted).
Notable bug fixes:
- Fix an issue where the
refactor
code-action would hang on large inputs. - The exports of a file with no value exports are typed as an exact empty object rather than an unsealed object. Common errors which resulted from this are accidentally doing
import typeof Foo
rather thanimport type {Foo}
- Fix error causing LSP requests to fail.
- Fix calling
watchman
on Windows. - Fix soundness issue when comparing polymorphic types (example try-Flow).
- Fix handling of duplicate bindings in signature builder.
- Improve error messages and type-at-pos results around
$ExactT<...>
type annotations. - Fix referencing
this
in a JSX title member. flow coverage
now returns 0% for non-@flow files; pass--all
to also check non-@flow files.- No longer attempt to provide definition or
flow get-def
on non-Flow files. - No longer attempt to provide hover or
flow type-at-pos
on non-Flow files - Update to latest LSP 3.17 beta definition of
CompletionItemLabelDetail
Library Definitions:
- Fix
navigator.clipboard.write
type and addClipboardItem
(thanks @Egrodo). - Add node.js
fs.copyFile
overload to support the case where themode
param is not specified (thanks @Brianzchen).
Misc:
- Removed the
flow suggest
command. - Improve codemod CLI error handling (Thanks @gnprice).
- Changed scheduling of LSP commands in parallel with typechecking, to prioritize commands.
- Removed
flow find-refs
command. - Removed the
--expand-type-aliases
flag from all Flow commands, it has caused several performance and non-termination issues without providing much value. - Improved codebase quality (thanks @gnprice).
Parser:
- Invalid
typeof
type annotations, where the argument totypeof
is a not a variable or member expression, are now parse errors rather than type errors.
New Features:
- The deprecated
*
type is now an alias toany
. You can useflow codemod replace-existentials
, which is available in previous versions of Flow, to upgrade your codebase to not use*
. This codemod command will not be available in the current or future versions of Flow. - Add (experimental) codemod to annotate variables that cause constrained write errors in future Flow versions.
- Add (experimental) codemod rename variable names that are reused with different types.
- Add --include-comments and --include-locs flags to the
flow ast
command. - Add $ObjMapConst<O, T> builtin type, alias for $ObjMap<O, () => T>.
Notable bug fixes:
- Fix bug in
$KeyMirror
so that it respects the optionality of its arguments. - Type
JSON
as object rather than a class. This prevents code such asnew JSON()
which is a runtime error.
Library Definitions:
- Add
InputEvent.dataTransfer
- Declare
AggregateError
class - fixes #8764 (thanks @lachlanhunt). - Improve
UIEvent
,InputEvent
andKeyboardEvent
types.
Misc:
- Fix typo in CONTRIBUTING.md (thanks @jereef).
- Clarify comments for ConcretizeTypeAppsT logic after Subtyping_kit refactor (thanks gnprice).
Parser:
- Fix a bug that allowed comments after the
#
in private identifiers.
- Fixes a bug with
experimental.prioritize_dependency_checks
- Fix a bug where errors in
node_modules
were shown in lazy mode. It is now consistent with non-lazy mode.
Likely to cause new Flow errors:
- As part of our work on Local Type Inference, unannotated variables now require a non-null value to be assigned to them at some point in the program. If a variable is intentionally only null, it can be annotated with
null
(let x: null = null
); if only undefined, then it can be annotated withvoid
(let x: void;
). - Function and class names can no longer be reassigned, even when not exported
- Fix positioning of [missing-type-arg] errors
New Features:
- Add
$Partial
utility type. This utility converts all of an object's or interface's named fields to be optional, while maintaining all the object's other properties (exactness, sealedness, etc).
Notable bug fixes:
- Improve performance of
strict_es6_import_export
- Fix an infinite recheck loop when deleting a file when using saved state
- Fix a bug where the server would stop after running a CLI command if the server was starting with
--autostop
Misc:
- Type
import.meta
as object - Fix jsdoc support on imported
declare function
- Make string literal autocomplete obey
format.single_quotes
setting - Improve reliability of "refactor" code actions
- Fixes a bug with
experimental.prioritize_dependency_checks
Likely to cause new Flow errors:
- Only consider variables as "constlike" if their assignments are within their declarations. This fixes cases of unsoundness. example. New Features:
- Add hierarchical document symbol support to the LSP. Improves VS Code's Outline pane, breadcrumbs and symbol search.
- Autocomplete now includes primitive types like
string
andnumber
, as well as utility types like$Call
and$Keys
.
Notable changes:
- Significantly improved overall performance.
Notable bug fixes:
- Unknown or redundant settings in the flowconfig
[lints]
section are now ignored when passing--ignore-version
. - Improve results of type-at-pos on
$ReadOnly
types.
flow-remove-types
:
- Added a Jest transformer,
flow-remove-types/jest
- The fix in 0.160.1 didn't fully fix the regression in 0.160.0. It, and the original "fix" from 0.160.0 are reverted.
- Fix a regression in 0.160.0 that caused suppressions to be ignored upon editing files in some cases when using lazy mode.
New Features:
-
The
ide
,fs
andwatchman
lazy modes have been merged into a single mode. The new mode is now SCM-aware with or without Watchman; when the server starts, it queries Git or Mercurial and checks all existing local changes (changes since the mergebase).The
file_watcher.watchman.mergebase_with
config option has been renamed tofile_watcher.mergebase_with
; set this to the name of your default remote branch (e.g.origin/main
).Flowconfig setting migration:
lazy_mode=watchman
->lazy_mode=true
,file_watcher=watchman
lazy_mode=fs
->lazy_mode=true
lazy_mode=ide
->lazy_mode=true
lazy_mode=none
->lazy_mode=false
-
Added parser support for
import.meta
-
Added type checking support for
new.target
andimport.meta
as mixed
Library Definitions:
- Add type for
queueMicrotask
Notable bug fixes:
- Improve codemod performance on large codebases
- Fix a bug that could cause "unused suppression" warnings to appear incorrectly when using lazy mode
New Features:
- Add support for git to watchman lazy mode. Git projects using
file_watcher=watchman
andlazy_mode=fs
can now upgrade tolazy_mode=watchman
. - Add codemod to convert
$ObjMapi<T, <K>(K) => K>
to$KeyMirror<T>
. Run it viaflow codemod key-mirror [OPTION]... [FILE]
.
Library Definitions:
- Add
devicePixelRatio
global (thanks @Brianzchen)
New Features:
- Add support for private class methods, implementing both the instance and static proposals! (thanks to our intern, @SamChou19815)
- Add an "Organize Imports" code action which sorts and groups the imports at the top of the file.
- Add an "Add all missing imports" code action which auto-imports all unambiguously undefined variables in the given file.
Notable changes:
- Fix a bug where private class fields like
#foo: () => 'foo'
could not be called, leading to workarounds likethis.#foo.call(this)
- Fix a crash when hovering over a type annotation that is recursive in a parameter default
- Fix a crash when autocompleting inside an object literal with a recursive type
- Fix order of auto-import code actions
- Fix issue with utility types nested in
$NonMaybeType<...>
- Fix Go to Definition on module reference strings (e.g. if
module.system.haste.module_ref_prefix=m#
,"m#Foo"
will jump to theFoo
module) - The
file_watcher.watchman.survive_restarts
setting is nowtrue
by default. This setting is deprecated and will be removed in a future version. - The
--retry-if-init
CLI flag has been removed. Setting it tofalse
previously caused the command to error if the server was already running but not yet ready. Instead, use--timeout
to avoid waiting too long.
Parser:
- Significantly improved parser performance
- Private methods are no longer a parse error
flow-remove-types
:
- Fix to remove variance sigils on class properties (thanks @mischnic)
Likely to cause new Flow errors:
- Add a new error for unreachable code occuring in a loop after a conditional with mixed
break
andcontinue
branches.
New Features:
- LSP extract to function/method/constant/class fields/type alias is enabled by default. These refactors will show up under after selecting some code. They can be disabled by adding
experimental.refactor=false
to the.flowconfig
. (thanks to our intern, @SamChou19815) - Add an eslint plugin,
eslint-plugin-fb-flow
, for eslint rules from the Flow team. The first rule isuse-indexed-access-type
to encourage the use of indexed access types (https://flow.org/en/docs/types/indexed-access/). - Add another eslint rule to lint against explicit exact by default syntax (fixes #8612).
- Add a command to
update-suppressions
to the flow tool (fixes #8384).
Library Definitions:
- Better coverage of the MediaTrackSettings API.
- Improve types for ResizeObserver (fixes #8693).
Misc:
- Upgrade to OCaml 4.10.2.
New Features:
- Cross-module autocompletion and code actions that fix missing import declarations are now enabled by default. This was experimental since
0.143.0
. Can be disabled per project with theautoimports=false
flowconfig option, or per user with theflow.suggest.autoImports
LSP configuration.
Library Definitions:
- Enhance the builtin Node.js module types (thanks @isker).
Fix bug in shared memory garbage collection which caused Flow to crash.
Likely to cause new Flow errors:
- Ban the use of
this
inside of object methods (see https://medium.com/flow-type/sound-typing-for-this-in-flow-d62db2af969e).
Notable bug fixes:
- Fix a bug with name collisions in declared modules (fixes #8604).
- Prevent showing identifiers for autocomplete of method names.
- Preserve interfaces when used with the
$ReadOnly
utility
Library Definitions:
- Add support for fs promises (thanks @atabel).
Likely to cause new Flow errors:
- Added type checking for
this
parameters of functions (see https://medium.com/flow-type/sound-typing-for-this-in-flow-d62db2af969e).
New Features:
- Added codemod to cleanup the use of soon to be deprecated existential type (e.g.
*
). It can be run viaflow codemod replace-existentials --write .
. - Added IDE quickfix for optional chaining when accessing an object that is nullable.
Notable bug fixes:
- Fixed crash related to a missing method unbinding error case.
- Fixed crash from calling the flow binary with an unknown argument.
Library Definitions:
- Fix MediaSource readyState to match the spec, "opened" -> "open" (thanks @sompylasar).
Misc:
- Remove
experimental.this_annot
config option and permanently enable now that our core lib defs rely on this feature. - Remove prevously defaulted on
new_check
config option for the new check mode that uses significantly less RAM for large projects.
Likely to cause new Flow errors:
- Enforce that interfaces are supertypes of objects and classes. Also prevent objects from being a supertype of a class.
- Improve soundness of
this
typing by banning the unbinding of class methods (see https://medium.com/flow-type/sound-typing-for-this-in-flow-d62db2af969e).
New Features:
- You can require an exhaustive check of an enum in a switch statement that includes a default branch. This is enabled with the comment
// flowlint-next-line require-explicit-enum-switch-cases:error
. - Autocomplete for object keys.
- Introduce a
flow fix
command to apply autofixes from the command line to a list of files. - Enable a new check mode that uses significantly less RAM for large projects.
Notable bug fixes:
- Fix a bug that allowed nested anonymous functions inside a default export.
- Using the
--ignore-version
flag also prevents Flow from crashing when an invalid option is in the.flowconfig
.
Library Definitions:
- Support the
options
parameter forrequire.resolve
. (thanks @skeggse) - Return a TypedArray instead of
void
from TypedArraysort
function. (thanks @goodmind) - Return a
DOMStringList
instead of a string array fromIDBDatabase.objectStoreNames
. (thanks @bnelo12)
Misc:
- Add
--binary
to theflow version
command to see the path to the current binary. - Prevent the LSP from exiting when an invalid option is in the
.flowconfig
. - Autofix for a
method-unbinding
error to replace the method with an arrow function. - Autofix for a
class-object-subtyping
error to replace the object type with an interface.
Likely to cause new Flow errors:
- Fixed an issue with refinement invalidation for variables without initializers or that are written to before they're declared. You may see both new errors from improved invalidations, and some unnecessary invalidations will be removed.
Notable bug fixes:
- Fixed the behavior of unary not operator on type applications
Library Definitions:
- Add
Symbol.asyncIterator
(thanks @goodmind) - Add missing methods to
HTMLTableSectionElement
(thanks @vitoreiji) - Fix nullability of various DOM table properties
- Fix type of
MediaRecorder
constructor options - Improve node
crypto
types (thanks @juodumas) - Improve node
cluster.worker
type (thanks @magicmark)
New Features:
- Add Smart Select IDE feature. This allows you to expand or shrink your selection based on the surrounding code. For example you might expand from an identifier to the containing expression, to the whole statement. In vscode, you can do this via ctrl+shift+cmd+(left or right arrow).
- Add Enum
getName(value: TEnum): string
method. Given a value of the enum type, this returns the string representation of the name of the member. You will also need to update to the latestflow-enums-runtime
package.
Notable bug fixes:
- Update
annotate-exports
codemod to add lowercasereact
instead ofReact
(thanks @meandmax!).
Misc:
- Improve developer setup on Windows by exposing internal setup scripts and updating the Windows setup
README.md
. - Enable
cache_live_errors_artifacts
andcache_signature_help_artifacts
config options by default. - Improve performance and reliability of Watchman integration.
- Error for use of
super
outside ofclass
methods added in0.148.0
has been removed.
Library Definitions:
- Update React types for React 18 release.
- Update the
Map
,WeakMap
,Set
andWeakSet
constructors' iterable param to be optional as per the ECMAScript spec. - Add typing for
PageTransitionEvent
as per the HTML spec (thanks @bripkens!). - Added support for
stepUp
andstepDown
inHTMLInputElement
declaration as per the HTML spec.
New Features:
- Suggest string literals in autocomplete in positions where string literal unions are expected.
Notable bug fixes:
- Use bracket syntax for autocomplete when autocompleting a property name that is not a valid identifier.
- Require the "main" property of
package.json
to have a valid Flow extension for the file to be considered. - Fall back to
.js
extensions even when a module name looks like a resource file (e.g../a.svg
will look to./a.svg.js
). - Fix a crash that occurred when checking a
this
parameter with a generic. - Make
$NonMaybeType<empty>
evaluate toempty
. - Honor format config options in more cases in code actions and codemods.
- Fix
PointerCapture
library definitions (thanks @malectro!).
Misc:
- Remove experimental
observedBits
param to React'suseContext
libdef. - Add caching to live errors and signature help, to speed up IDE interactions (currently behind temporary flags).
- Introduce
format.bracket_spacing
option which affects code output (such as code actions). - Improve the sorting of autoimport suggestions that have the same name, so that the module's file extension is not considered.
New Features:
- Added autocomplete for member expressions that use bracket notation
Notable bug fixes:
- Improved typechecking for expressions like
obj[Symbol.iterator]
. This is now correctly typed as the object type's@@iterator
property.
Misc:
- Removed
esproposal.class_instance_fields
,esproposal.class_static_fields
,esproposal.decorators
,esproposal.export_star_as
,esproposal.nullish_coalescing
andesproposal.optional_chaining
flowconfig options which have been deprecated since v0.135.
Likely to cause new Flow errors:
- We now error if the RHS of instanceof is not an object, e.g.
x instanceof null
. This catches'instanceof' is not an object
runtime errors. - Using
super
outside of class methods, e.g. in arrow and function properties, is now an error.
Library Definitions:
- Add
static from
tostream$Readable
(thanks @agalatan).
Notable bug fixes:
- Fixed autoimports to not suggest vars already in scope.
- Fixed autoimports to reuse existing imports if they exist.
- Fixed autoimports to correctly sort imports of the same name.
- Fixed
null
from being a subtype of an empty interface e.g.(null: interface {}) // Error
(thanks @mrtnzlml for the report).
Misc:
flow refactor
experimental command removed. Instead, use the LSPtextDocument/rename
request.- Removed the
experimental.new_signatures
flowconfig option as well as the--old-signatures
opt-out command line flag.
Likely to cause new Flow errors:
- This release includes some significant architectural changes that fix bugs, improves performance, and may cause Flow to find more errors.
- Fixed a bug where "maybe types" like
?{c: number}
did not properly error when used with utility types$PropertyType
and$ElementType
.null
andundefined
do not have properties nor elements. Object.prototype
properties liketoString
andhasOwnProperty
are no longer allowed to be accessed as global variables, which was previously allowed becausewindow
is an object.
New Features:
- Added Linux ARM64 support. A precompiled binary is provided, including through
flow-bin
.
Notable bug fixes:
- Improved the error message when getting properties on
null
andundefined
- Fixed running
flow lsp
on symlinked root directories
Misc:
- Removed support for
@flow weak
, which was a rarely-used mode in which missing annotations were treated asany
. It is equivalent to suppressing any type errors that result from just using@flow
. So to migrate, suppress the new errors and removeweak
. - Fixed a bug in which the built-in library definitions could be missing
- Fixed an obscure crash when using Watchman and Mercurial
- Added support for a
flow.suggest.autoImports
LSP setting to disable autoimport suggestions in autocomplete (currently requiresautoimports=true
to be enabled in.flowconfig
)
Library definitions:
- Added support for node's
assert
strict mode (thanks @goodmind) - Added support for
.webp
resources (thanks @TomasBarry) - Added missing Brotli APIs to the zlib module (thanks @isker)
- Added missing methods to
tty.WriteStream
(thanks @reyronald) - Changed
process.exit
to returnempty
Parser:
- Fixed a regression in 0.146 where flow_parser.js defined some global variables
Likely to cause new Flow errors:
- The rules around when refinements are invalidated have been strengthened for increased accuracy, and Flow will now invalidate refinements in a number of locations where they were not previously invalidated. This may expose new Flow errors due to variables that were previously refined to a more specific type now being treated as the unrefined, more general type.
- Object literals now have covariant subtyping with interfaces
- Interface optional properties are no longer unsafely covariant in all cases
- Interfaces with indexed properties are now properly supertypes of classes/objects with named properties matching the indexer
interface {}
is no longer a supertype ofvoid
andmixed
Notable bug fixes:
- Properties that begin with a
.
were sometimes being ignored by Flow, which has now been fixed
Library Definitions:
- Added missing attributes to
PerformanceResourceTiming
library definition (thanks @MIGreenberg) - Added
withFileTypes
option toreaddir
andreaddirSync
(thanks @mrtnzlml) - Added
composedPath
function toEvent
library definition (thanks @Brianzchen) - Added JSDocs to
Event
library definition and made most properties read-only
Misc:
- New flowconfig options to set garbage collector parameters for workers. The new flowconfig options are
gc.worker.custom_major_ratio
,gc.worker.custom_minor_ratio
,gc.worker.custom_minor_max_size
,gc.worker.minor_heap_size
,gc.worker.major_heap_increment
,gc.worker.space_overhead
, andgc.worker.window_size
.
Likely to cause new Flow errors:
- Correctly typecheck destructuring defaults in function params. e.g.
function i({name = 1}: {| name?: string |}) {}
was previously not an error.
New Features:
- New options added to
flow_parser.js
to support configuring comment output.comments
enables comment attachment andall_comments
enables the legacy list of all comments.
Notable bug fixes:
- Correctly handle import paths within
node_modules
for auto imports. - Fixed a bug in Go to Definition on imported values that skipped all the way to the value's type definition instead of the value's definition.
- Fixed a bug in autoimport code actions that resulted in
import type { type T } ...
- Improved generic type checking launched in v0.140. The deprecated implementation and the temporary
generate_tests=true
flowconfig option have now been removed. - Fixed an issue with logical operators (
&&
,||
,??
) and union types - Object rest properties (
let {foo, ...rest} = obj
) now retain the indexer of the object being destructured. In this example, ifobj
is{[string]: string}
, thenrest
is also{[string]: string}
. - Made the parser recover gracefully in some cases when in the middle of typing, allowing language services to work better in the rest of the file
- Improved experimental cross-module autocomplete to include globals and built-in modules. Can be enabled with the
autoimports=true
flowconfig option. - Fixed a bug so that the server no longer exits when merely
touch
-ing the.flowconfig
without changing it
Notable bug fixes:
- Fixed crash on Windows and crash on Linux introduced in 0.143.0
Likely to cause new Flow errors:
- Support for Classic mode has been dropped and Types-First mode is now always enabled (Types-First has been the default mode since v0.134). The
types_first
andwell_formed_exports
flowconfig options are no longer recognized. See https://medium.com/flow-type/types-first-a-scalable-new-architecture-for-flow-3d8c7ba1d4eb/ for more about Types-First mode. - Previously, errors in library files were sometimes being missed due to a bug. This has been fixed, which may expose errors in library files that were not previously being reported.
- Import statements are no longer allowed at the toplevel of library files. To use import statements in library files they must appear within a "declare module".
New Features:
- Added experimental support for cross-module autocompletion and code actions that fix missing import declarations. Can be enabled with the
autoimports=true
flowconfig option. - Added
--sharedmem-heap-size
CLI flag andFLOW_SHAREDMEM_HEAP_SIZE
environment variable, which can be used instead of thesharedmem.heap_size
flowconfig option for setting the amount of shared memory available.
Misc:
- Added
ErrorEvent
library definition (thanks @kegluneq)
Likely to cause new Flow errors:
- Disallow flowing functions or inexact objects to indexed objects to improve object soundness. This can cause errors if you are passing a function or inexact objects when an indexed object is expected.
- Flow now processes imports before checking the body of a file. In some rare cases this can expose previously skipped errors due to the processing order.
Notable bug fixes:
- Fix
No available version of ocaml-base-compiler satisfies the constraints
error frommake all-homebrew
(thanks @bayandin).
- Improved inference of chained generic method calls, such as
Array
methods. For example, given[1, 2].map(a => a).forEach(b => b)
, Flow now infers thatb
is anumber
rather thanany | number
. - Fixed non-termination bugs involving recursive types
- Fixed a non-termination bug involving implicit instantiation with
_
- Fixed autocomplete so it no longer inserts a
=
in JSX attributes that already have one - Hovering over a use of an opaque type now includes the type's documentation
Likely to cause new Flow errors:
- New generic type checking is now enabled by default, and has to be explicitly disabled with
generate_tests=true
in a flowconfig if desired. See https://medium.com/flow-type/flows-improved-handling-of-generic-types-b5909cc5e3c5 for more about Flow's new handling of generic types.
Notable bug fixes:
- Fixed "Could not locate flowlib files" errors when multiple users run Flow on the same machine
- Fixed autocomplete and hover for imported enum types
- Fixed autocomplete suggesting types in value positions
- Fixed a bug where correct non-boolean predicate functions were rejected
Parser:
- ESTree AST now uses Literal node for init of boolean enum members
Misc:
- Updated
ShadowRoot
library definition (thanks @Brianzchen)
New Features:
- Support for
this
annotations in functions, likefunction f(this: {foo: string}, param1: string): string { return this.foo; }
- The
experimental.abstract_locations
config option is nowtrue
by default, as it enables significant performance improvements. This option is now deprecated and will be removed in a coming version.
Notable bug fixes:
- Fixed a false positive when a bounded generic like
K: string
flows into$Keys<{[K]: ...}>
- Fixed a false positive when a bounded generic like
K: 'literal'
is checked against itself likek === 'literal'
- Fixed autocomplete inside of JSX attribute values
- Fixed autocomplete of properties of interfaces
Misc:
- Updated
flow-remove-types
to supportthis
parameters - Added SpeechRecognition definitions (thanks @ayshiff)
Likely to cause new Flow errors:
- Improved positioning of existing errors involving unions or intersections. Will not cause new errors, but may require suppressions to be moved.
Bug Fixes:
- Fixed soundness bug involving union and intersection types
- Improved performance of typechecking exact objects against
$Exact
Editor Integration:
- Fixed hover and go-to-definition over the LSP when the cursor is at the end of a token
- Fixed type coverage over the LSP when using
all=true
(thanks @mochja) - Fixed an issue with running the
flow
CLI at the same time as VS Code caused by case-insensitivity of Windows paths
Library Definitions:
- Added
inputType
toInputEvent
(thanks @Brianzchen) - Added
intersectsNode
toRange
(thanks @Brianzchen)
Misc:
- Built-in library definitions are now extracted to a consistent temp directory, like
/tmp/flow/flowlibs_<HASH>
, to take up less space.
New Features:
- Show code actions in the IDE for some parse errors with suggested fixes.
Notable bug fixes:
- Fixed infinite recursion case involving object rest destructuring.
Library Definitions:
- Changed return type of
Buffer.write
tonumber
(thanks @fedotov).
Misc:
- Saved state files generated on one platform can now be used on another platform using the same version of Flow.
- Improved saved state memory use and startup time with more efficient handling of file paths.
- Improved error message when attempting to bind a class type.
- Minimum supported MacOS version is now 10.13.
Likely to cause new Flow errors:
- Flow now raises errors when generic type variables escape out of the scope in which they were defined.
Notable bug fixes:
- Fix a race condition related to saved state and cancelable rechecks that caused internal errors of
Requires_not_found
orSig_requires_not_found
.
Misc:
- Added documentation to core.js builtins.
- Add optional
propTypes
toReact.AbstractComponentStatics
(thanks @brianzchen).
Likely to cause new Flow errors:
- Turned the untyped-type-import lint into an error by default. In a later release, we will turn this into a regular type error instead of a lint error.
Misc:
- Improved exhaustiveness checking in switch statements.
- Improved autocomplete results to show documentation in more cases.
- Removed esproposal configuration options from the .flowconfig format.
- Added library definition for MediaRecorder API.
- Fixed Object.freeze to no longer incorrectly convert an inexact object into an exact object.
- Fixed handling of exported objects with spreads in types-first mode.
Likely to cause new Flow errors:
- Types-first is now the default mode, and has to be explicitly disabled with
types_first=false
in a flowconfig if desired. See https://medium.com/flow-type/types-first-a-scalable-new-architecture-for-flow-3d8c7ba1d4eb for more about types-first.
New Features:
- Added a
file_watcher.watchman.mergebase_with
flowconfig option and--file-watcher-mergebase-with
CLI option to choose a tracking bookmark for Watchman to compute the mergebase against. - Show JSDoc documentation in type declarations.
Misc:
- Improved the consistency of what operation is pointed to in error messages, to ensure they aren't dependent on the order in which constraints are generated.
- Filtered "did you mean" code actions to only send actions on code under cursor.
- Changed the return type of fileURLToPath (thanks @aaronasachimp)
Likely to cause new Flow errors:
- Improve reliability of inclusion check in strict equality conditionals.
New Features:
- Show JSDoc documentation in hover, autocomplete, and signature help.
Notable bug fixes:
- Fix a bug related to saved state that could cause crashes during initialization.
- Fix a bug related to saved state that could cause internal errors during rechecks.
- Fix crash with
flow focus-check
when a focused file has a syntax error.
Misc:
- Remove the
null-void-addition
lint now that it has been subsumed by an ordinary type error. - Improved signature help for inlined tuple rest params.
- Enable the following language features by default, since they have reached stage 4:
export *
- Nullish coalescing
- Optional chaining
- Remove deprecated, nonstandard
itemType
andinlineDetail
fields from the LSPcompletionItem
implementation. - Exit the worker processes gracefully when the main process crashes.
Likely to cause new Flow errors:
- Disallow using any-typed values type annotations. example
New Features:
- Added warnings against suppressions without error codes
Notable bug fixes:
- Fixed some crashes when Flow could not connect to Watchman
Misc:
- Fix syntax errors in README badges (thanks @jamesisaac)
- "Go to Definition" on a JSX attribute name now jumps to the prop's type.
- Improved error messages for non-strict equality checks
- Fixed a bug that prevented the use of
module
in ES modules whenwell_formed_exports
is enabled. - Fixed an issue that allowed types-first mode to be enabled (
types_first=true
) when usingwell_formed_exports.include
. For types-first to function properly, the entire project's exports must be well-formed, not just specific paths. - Fixed a similar issue so that
--types-first
on the command line overrideswell_formed_exports=false
in.flowconfig
. This makes it easier to test types-first mode. - The
unsafe-addition
lint now defaults to being an error. It will be converted from a lint to a type error in the future. - Removed
dynamic-export
lint which does not work in types-first mode - Improved initialization performance
New Features:
- Improved IDE get definition behavior of imported names by jumping past
module.exports = ...
to the actual definition.
Library Definitions:
- Made
offset
an optional argument for the sized Buffer read/writes (thanks @isker!)
Misc:
- Removed deprecated blacklist/whitelist aliases for config options, use
includes
/excludes
instead (see updated docs: for Types First and flowconfig options).
Likely to cause new Flow errors:
- $Keys<...> will no longer include non-own instance properties, matching the behavior of Object.keys.
Notable bug fixes:
- Fixed an incremental rechecking issue caused by the hashes of type destructors
Misc:
- Updated the type of
cast
andisValid
to take in optional representation type for enums - Added missing links to Medium articles from flow.org (thanks @jamesisaac)
New Features:
- Enable LSP support for autofix exports by default.
- Added a lint rule to ensure exports named
default
were exported withexport default
syntax. - Enabled support for JSDoc in some LSP results.
Library Definitions:
- Add parameter to MediaStreamTrack.applyConstraints()
Parser:
- Fix parsing async arrow functions with multiple type parameters
Config:
- Remove types-first flag aliases prefixed with "experimental"
- Replace well_formed_exports.whitelist with well_formed_exports.includes
Misc:
- Improvements to editor in flow.org/try, including syntax highlighting
- Fix broken links in docs
- Standardized error suppression syntax, added ability to suppress errors based on error codes
Library Definitions:
- Add KD functions
- Add onended callback to OscillatorNode
- Make 3rd parameter of node.js symlinkSync optional
- Fixed an issue where changing
.flowconfig
orpackage.json
and then runningflow status
would get stuck in a restart loop, if using lazy mode with Watchman and Mercurial.
- Allow indexers in exact object annotations
- Fixed type-at-pos in flow.org/try
- Improved language of LSP
window/showStatus
responses - Improved control flow handing in logical expressions
- Allow applying utility types to opaque types in the defining module
- Added
HeadersInit
andsignal
to Fetch API (thanks @andretshurotshka!) - Added
replace
method toDOMTokenList
(thanks @w01fgang!)
Publishing of flow-bin
v0.125.0 failed to include the binaries. Oops!
Likely to cause new Flow errors:
- Fixed signatures generated in types-first for classes with non-trivial expressions
in their extends clauses, which were before treated like extending
any
.
New features:
- Types-first is no longer an experimental mode, but is now fully supported!
Notable bug fixes:
- Fixed a soundness bug that allowed refined property expressions to be treated as
empty
in some circumstances.
Misc:
- Added
$FlowIssue
and$FlowExpectedError
as default suppression comments. - Improved quality of AST and comment printing and layout.
- Improved quality of type printing for
type-at-pos
and friends. - Add '.cjs' as a default extension.
Parser:
- Fixed ranges of sequence and assignment expressions that contain grouping parentheses.
- Disallowed newline after
type
keyword in type aliases.
Library definitions:
- Added headers timeout to http & https server (thanks, @mattconde!)
- Added flushHeaders to http$ServerResponse (thanks, @gajus!)
- Changed
thisArg
parameter for array callback functions (e.g.map
,reduce
) tomixed
. - Added more precise typing for common cases of
Array.flat
.
Library Definitions:
- Add
StorageEvent
overloads.
Misc:
- Use
textEdit
in identifier completion item responses over the LSP, to avoid possible behavior differences with different LSP clients. - Various improvements to the pretty-printer.
- A small improvement in completeness when handling the "not" operation in the presence of unions of literal types.
- Wrap the usage message to 100 chars.
- Fix a poorly-positioned error related to polymorphic function types.
Parser:
- Improved some parser error messages by treating the end of file as a valid end of object property.
- Updated ESTree output for import expressions to match the spec.
flow-dev-tools
:
- Add the
update-suppressions
subcommand.
New Features:
- Added support for the babel react jsx transform with the
react.runtime
flowconfig option. When set toautomatic
the transform auto-imports jsx (the replacement forcreateElement
) under a fresh name (unique of all existing names in the source). When set toclassic
it will continue transpiling jsx toReact.createElement
.
Notable bug fixes:
- We are now treating
$Exact<T|U>
as$Exact<T>|$Exact<U>
. Before, when we checked against this type we would treat it like$Exact<T> & $Exact<U>
, instead. - Fix to prevent infinitely expanding recursive type applications of arrays (example).
Misc:
- Improvements in comment attachement in various kinds of AST nodes. These will help improve the accuracy of error suppression and various services that inspect comments (printing, showing documentation, etc.).
$Exports<'m'>
will now lookup module 'm' directly in builtins, instead of the environment.- Extend union optimizations used on maybe predicate to also be applied in exists predicates.
Parser:
- The range around type cast expression now includes the parentheses. This follows the pattern of other constructs with mandatory punctuation like blocks, objects or arrays.
Likely to cause new Flow errors:
-
Moved
react-dom
modules out of built-in libdefs. They are now available on flow-typed.To install the libdefs, run
flow-typed install --flow-version=0.122.0 [email protected]
This diff is necessary to allow React to make breaking changes to react-dom without force-pinning Flow users to the latest version of react-dom.
-
Fixed an unsoundness in union and intersection spreads
-
Improved object spread-related error messages, which may cause suppressed errors to become unsuppressed because they moved to better locations
Improved Editor Integration:
- Removed completion of function param snippets. Before,
f<tab>
might completefoo(aParam)
, which is problematic if you don't want to call the function. Now it just completesfoo
. These snippets are further obviated by signature help, which appears when you type(
. - Improved accuracy of "Did You Mean?" Quick Fixes for object property type errors
- Added support for Go to Definition on export-from declarations (
export { HERE } from ...
) - Fixed tracking of open files in LSP clients which could cause stale errors in the IDE
Misc:
- Added
HTMLUnknownElement
and support for custom elements todocument.createElement
(thanks @YevhenKap!) - Fixed
--saved-state-no-fallback
flag so that Flow exits when saved state is not found - Fixed an issue where an invalid package.json would prevent generating saved state
- Fixed a potential deadlock when communicating with Watchman
- Fixed types-first signatures for CJS requires introduced with var
- Enabling
experimental.types_first
now impliesexperimental.well_formed_exports
Parser:
- Renamed
RestProperty
toRestElement
to match estree - Changed 'for await' nodes from
ForAwaitStatement
toForOf
withawait: true
to match estree
Highlights:
- Made several improvements to errors:
- Restricted errors to only be suppressible at the error's primary location (see blog post)
- Fixed the error grouping logic to no longer group unrelated errors that happen to share a location
- Changed the order of locations printed in error messages so that the primary location is always printed first (which is the one you need to suppress if you want to do that)
Misc:
- Fixed the
add-comments
script to add comments onJSXText
- Fixed a crash when TMPDIR exceeded 83 characters
- Stopped parsing
.flow
files without@flow
Lib defs:
- Improved definitions for Node's
url.parse
function (thanks @chicoxyzzy) - Added missing
console
methods (thanks @goodmind) - Added
Element.hasAttributes()
- Added
string
index toNamedNodeMap
- Fixed
Element.querySelector()
andElement.querySelectorAll()
overloads - Added type definition for
Promise.allSettled()
Likely to cause new Flow errors:
$Shape
types now carry more information about the locations of errors that involve them, which may invalidate old suppressions.any
-typed values are now refined by primitivetypeof
checks (example).
New Features:
-
"Did You Mean?" IDE feature that suggests corrections to your code as you type. For example, if you write foo.bar on an object foo that doesn’t have a field named bar but does have a field named baz, the quick fix will apply that suggestion.
-
declare
can now be used on class fields. When Flow implemented the class fields proposal, uninitialized class fields (e.g.class C { foo }
) were not allowed, so we used that syntax for type-only declarations (class C { foo: string }
). Since then, they now are initialized toundefined
and Babel 8 will start to leave them. To maintain existing behavior, change uninitialized fields to use thedeclare
keyword, signalling to Babel that they should be stripped (class C { declare foo: string }
).
Notable bug fixes:
- Fixed possible stack overflow from overly long traces.
- Fixed infinite recursion case involving polymorphic types.
- Various improvements to the output of
type-at-pos
andsignatureHelp
Misc:
- Fixed libdefs of
Notification
to have read-only fields
Notable bug fixes:
- Fixed a bug that would cause Flow to crash on some rechecks.
New Features:
- Implemented LSP textDocument/signatureHelp, which shows parameter hints when you are within an argument list in a call or
new
expression.
Misc:
- Removed the
minimal_merge
flag - Added optional callback for node dgram socket.close function (thanks @davidnaas!)
Parser:
- Made arguments on
new
expressions optional
New Features:
- Autocomplete for nullable objects will now suggest completions with optional chaining syntax
- Added a new lint,
unsafe-addition
, which warns if either operand of an addition isnull
orvoid
Breaking change:
- The output of
flow autocomplete --json
no longer includes location information. This might affect some IDE integrations which have not yet updated to Flow's LSP server. The LSP integration is unaffected.
Misc:
- Added the
dir
field to theDocument
libdef (Thanks, @lukeapage!)
- Improved timeouts related to Watchman that could cause the server to fail to start if Watchman is slow to respond. Added a
file_watcher_timeout
.flowconfig option and--file-watcher-timeout
argument toflow start
andflow server
, which defaults to 120 seconds.
Notable bug fixes:
- Improved the behavior of
$Diff
and other type destructors when applied to unions.
Misc:
- Improved error messages when attempting to use watchman without watchman installed.
- Removed uses of
Symbol
from libdefs in favor ofsymbol
. - Fixed definition of
fs.promises.mkdir
(thanks @gabrielrumiranda!)
Notable bug fixes:
- Fix #8259.
New Features:
- Flow now suggests similar names (if applicable) when issuing missing property errors.
Misc:
- Added a rudimentary libdef for
Array.prototype.flat
(#8237, thanks @nnmrts!). - Fixed a bug that in certain specific cases led to an expression getting typed as
empty
rather thanany
.
Parser:
>
and}
in JSX child text is a parse error.
Likely to cause new Flow errors:
- In Types First mode, exported classes and functions cannot be reassigned.
- Added similar checking of
symbol
in non-strict equality as other primitive types (example). We allow for non-strict equality checks between two symbol types, and between a symbol and null/void (example). - We now write properties to unsealed objects recorded during speculative checking, after speculation has succeeded.
- Added more complete handling for indexers in spreads:
- Removed the
non-array-spread
lint, and replaced it with a new .flowconfig option,babel_loose_array_spread
.
Notable bug fixes:
- Improved union optimization for non-enum union equality checks.
- Fixed a bug in which
$Exact<T>
failed whenT
resolved to aShape<T>
. [example]
Misc:
- Improved performance of calculating the set of files that need to be checked.
- Cached the typed AST as part of the persistent connection client info, to speed up requests coming from an LSP client (DefinitionRequest, Hover, TypeCoverage).
- Improved dependency graph construction times, by using Hashtbl and mutable back edges.
- Improved
tool add-comments
by- using
flowlint-next-line
instead of adding full$FlowFixMe
suppressions on lints, and - making the rule for inserting comments inside JSX elements also apply to JSX fragments.
- using
- Upgraded to sedlex 2.1.
Upgrade internal dependencies sedlex and lwt. Lwt includes a fix to stack traces that we need to debug crash logs.
Likely to cause new Flow errors:
- Fixed the order of evaluation of JSX attributes and children to match runtime, so that refinements work properly. This can lead to new errors if refined values are used as children, and a function is called within an attribute, because the refinements are now invalidated in a different order. On the other hand, calling a function in a child no longer incorrectly invalidates values used as attributes. [example]
- Added support for refinements on optional chains! Now, examples like
if (x?.y)
andif (x?.y === 42)
understand thatx
is truthy in the consequent. Flow also now refines subexpressions of optional chains. For example, givenobj?.fun(obj.value)
, the secondobj
is known to be truthy since it is only reachable if the earlierobj?.fun
is also truthy; therefore, you don't need to optional-chain it again (obj?.value
).
New Features:
- Added typechecking support for
symbol
! Note that just likenumber
is not aNumber
, and vice versa,symbol
is not aSymbol
. In the core lib defs, we change usage ofSymbol
tosymbol & Symbol
. Eventually, it will just besymbol
. Thesymbol & Symbol
is temporary for one version to allow for existing usage of the: Symbol
to be codemodded to: symbol
.
Bug fixes:
- Optimized typechecking pointwise-equal unions, from O(n^2) to O(n)
- Optimized reverse dependency computation, greatly reducing the time spent computing what needs to be rechecked after an edit
- Fixed an error message that pointed at the definition of a write-only property instead of the callsite that tried to read it [example]
- Fixed an issue where coverage results could be incorrect in Types First mode when a file is rechecked
- Fixed an issue when Flow prints evaluated types like
$ElementType
, that led to printingempty
instead. This improves hover tooltips. - Fixed several issues causing various processes to die uncleanly while exiting.
Bug fixes:
- Fixed autocomplete when at the end of file
- Stopped filtering lints (e.g.
signature-verification-failure
) out when runningflow check-contents
Parser:
- Added support for
export default class implements Foo {}
[example] - Added support for type parameters in anonymous class expressions [example] (thanks @nicolo-ribaudo)
Library definitions:
- Fixed type of
navigator.mediaDevices.getUserMedia
(thanks @thecotne) - Added missing
InputEvent
toremoveEventListener
- Updated type of
ServiceWorkerContainer.getRegistration
Misc:
- Added
module.system.node.main_field
option (see #8128 for more details)
Likely to cause new Flow errors:
- JSX expressions now use the new spread semantics added in v0.111.0
- Attempting to write to or update a read-only property using operator assignment is now a type error
New Features:
- New
ambiguous-object-type
lint warning against use of{}
object types (prefer{||}
or{...}
instead, even whenexact-by-default
is enabled). - Improved support for optional chaining
Notable bug fixes:
- Malformed type annotations no longer trigger the
unclear-type
lint error - Builtin classes can no longer be extended
Misc:
- Improved performance for utility types and refinements in unions
- Various improvements to autocomplete and get-def IDE services
- Add
useDeferredValue
anduseTransition
to React library definitions - Add
bytesWritten
funciton to library definition (thanks @farzonl)
Notable bug fixes:
- 0.111.2 did not include the commit that bumped the Flow version inside of Flow. (@jbrown215 was a clown)
Notable bug fixes:
- Spread performance improvements that can prevent timeouts in extreme cases.
New features:
- Add
module.system.node.root_relative_dirname
to allow you to configure where root relative paths resolve to
Notable bug fixes:
- Fixed the regex generator that handles the magic string in Flow suppression comments
- Allow spreads of bools, strings, and numbers to support common React Native patterns
Likely to cause new Flow errors:
- Fixes to object spread. See https://medium.com/flow-type/spreads-common-errors-fixes-9701012e9d58
New features:
- Introduced an experimental flag (
experimental.minimal_merge
) that speeds up rechecks when the experimental types-first mode is in use. This flag will be turned on by default and then removed in future releases. - Turned on
experimental.allow_skip_direct_dependents
by default. The flag will be removed next release. This flag speeds up rechecks when the experimental types-first mode is in use.
Notable bug fixes:
- Fixed a bug where the ocaml representation of union types caused crashes in rare scenarios
- Fixed a bug in node module resolution which allowed
module.system.node.resolve_dirname=.
. For those who relied on this bug to import modules using root-relative paths, you can now usemodule.system.node.allow_root_relative=true
. See #8156 for more details.
Misc:
- Add getElementById to DocumentFragment
- Add missing methods to Blob (thanks @lyleunderwood!)
- Allow clients of
flow status
,flow check
, etc. to choose character offset style - Support length refinement on tuples (thanks @ilya-bobyr)
Parser:
- Allow => in objects in return types of arrow functions
Notable bug fixes:
- No longer show live Flow errors for files without @flow, unless
all=true
in the.flowconfig
- No longer show live Flow errors for ignored files
- Re-generate live errors after a recheck
New Features:
- Flow will now send type errors as you type to LSP clients. To disable this behavior, add
experimental.disable_live_non_parse_errors=true
to the[options]
section of your.flowconfig
.
Notable bug fixes:
- Fixed file descriptor leak leading to LSP connection refusal in some cases
- Improved the behavior of the
[declarations]
configuration in the presence of dependency cycles (thanks @STRML!)
Misc:
- Added
--evaluate-type-destructors
totype-at-pos
command. - Added
--evaluate-type-destructors
and--expand-type-aliases
todump-types
command (thanks @goodmind!) - Changed
proceses.env
values from?string
tostring|void
(thanks @FireyFly!) - Improved detection of rebases when using watchman file watcher
- Improved positions for error messages involving the deprecated
*
type
Likely to cause new Flow errors:
- Flow was previously not typechecking
delete
, but now does Object.defineProperty
and similar methods now adhere more closely to the spec- Allow defaults for properties that may not exist in React components
Notable bug fixes:
$NonMaybeType<mixed>
no longer includes null and undefined (Thanks @goodmind)
Misc:
- Deprecated
$Supertype
and$Subtype
utilities are now removed entirely - flow-upgrade should now use https over git (Thanks @lukeapage)
- Autocomplete now fires on spaces in JSX
- Better error messages when a value is used as a type
Performance:
- Reduced memory usage by using a more compact representation for code locations
- Types-first should no longer check direct dependents of files where the signature has not changed
Library Definitions
- Add a number of CSSOM interfaces + fix
HTMLStyleElement.sheet
type (Thanks @kof) - Add
AsyncIterator
tonode.js
(Thanks @goodmind) - Add
undefined
to prelude (Thanks @goodmind) - Add String.prototype.matchAll (Thanks @goodmind)
Notable bug fixes:
- Batch coverage info now persists through rechecks.
- When a file with @preventMunge is in a cycle with a file that does not, the un-munged file no longer has exported munged properties checked for annotations.
- Fixed a bug where autocomplete would not be triggered in a file with Windows-style line endings.
- Improved error messages for uses of
$ObjMap
,$ObjMapi
,$TupleMap
, and$Call
with incorrect arity.
Misc:
- The deprecated
flow ide
command and associated machinery have been removed.
Library definitions:
- Added the missing parts of the Pointer Lock spec to libdefs.
- Thanks to @lyleunderwood for adding scrolling support to libdefs.
- Thanks to @goodmind for adding a definition for
undefined
to the prelude.
New Features:
- Implement type refinements for property accesses through brackets (#7597, thanks @goodmind).
Notable bug fixes:
- Fix several issues with autocomplete that prevented optional properties, type aliases to utility types, types with default type arguments, and several other edge cases from being autocompleted.
- Fix Not_expects_bounds crash with
%checks
(#7863).
Misc:
- Make the LSP
textDocument/documentHighlight
request serviceable while Flow is in the middle of a recheck. - Fix minor off-by-one error which caused some parts of traces to be pruned when using the
--traces
flag. - A minor improvement in error messages when
undefined
is involved. - Reduce memory usage slightly when abstract locations are enabled.
- Prevent log spew when
flow lsp
is started while the server is initializing. - Improve completeness of sighashing. We recently observed an incremental bug caused by incomplete sighashing. This speculatively addresses similar potentially problematic cases.
Library Definitions:
- Add webkitGetAsEntry to DataTransferItem.
- Switch several properties to optional in Notification and NotificationOptions (#8032, thanks @pauldijou).
- Map/Set fix symbols (#7560, thanks @goodmind).
- Fix Array#reduce and Array#reduceRight (#7902, thanks @goodmind).
We found and fixed a bug introduced in 0.105.0. Some internal code was using a hashing function and assumed collisions were far less likely than they proved to be. This could lead to random nonsensical errors which would then disappear, usually involving missing object properties. This likely only affected extremely large projects.
Fixed the stack overflow reported by #8037. Thanks @lukeapage for isolating the repro!
Forgot to cherry-pick [rollouts]
(an experimental new .flowconfig section) into v0.106.0
Likely to cause new Flow errors:
- We're starting to make changes to how Flow models object spreads. For more see this announcement
- Updated parsing of the experimental nullish coalescing
??
operator. It now has a lower precedence than||
and&&
, and parentheses are required to nest it with them. - Flow wasn't typechecking the properties of certain obscure JSX usage (namespaced identifiers, member expression with @jsx / @csx), so would miss type errors in their expressions (e.g.
<a:b prop={"hello" * 10} />
now errors)
Notable bug fixes:
- Fixed a bug where merge or check jobs would crash when a parse error was added to a file in a cycle. The crash was silent but unintended.
- Types-first no longer ignores the
munge_underscores
flowconfig option
Misc:
- Various libdef updates. Thanks for all the PRs!
Parser:
- Improved error messages for missing semicolon
- Comments are now correctly attached to
break
statements and array patterns libflowparser
now supportsesproposal_nullish_coalescing
as an option
v0.105.0 started running the Flow server in a cgroup on Linux distros that support cgroup v2. However, some versions of systemd
, which manages cgroups, contain a bug that caused the Flow server to fail to start. This release avoids using cgroup
on these systems. (#8012)
This was an npm-only release to fix a packaging issue. No updated binaries were published.
Likely to cause new Flow errors:
-
Types for
FileReader
properties and methods are now more precise (e.g., some parameters typedany
are now typedProgressEvent
; some properties now havenull
added to their types). Thanks, @nwoltman! -
The value type parameter
V
of$ReadOnlyMap
and$ReadOnlyWeakMap
is now covariant. Thanks, @goodmind! -
Types for the
vm
module in node.js are now more precise. Thanks, @goodmind! -
The deprecated
$Enum<...>
utility type has now been deleted. Use$Keys<...>
instead. -
Indexing tuples with floats is no longer allowed.
New Features:
-
Added support for
React.Profiler
(React v16.9+). Thanks, @bvaughn! -
Added a
--types
flag toflow graph dep-graph
to output only "type" dependencies: the subset of imports that the types of a module's exports depends on. (Without the flag, we output "code" dependencies: the set of all imports of a module.) -
Preliminary support for automatically inserting annotations on a module's exports through LSP. Thanks to @akuhlens (summer intern with the Flow team)!
-
Preliminary support for definite assignment checking of class instance properties. Thanks to @pzp1997 (summer intern with the Flow team)!
-
Added an option to
.flowconfig
for exact-by-default objects.
Perf fixes:
- Fixed a non-termination issue with a recursive use of mapped types.
- Fixed an exponential-blowup issue with a combined use of spreads and unions.
- Fixed an exponential-blowup issue with recursive use of array spreads.
Misc:
- Fixed LSP init to say codeLens is not supported.
- Fixed lots of cases of bad error positioning, unblocking improvements to error suppressions and error streaming. Thanks to @mvcccccc (summer intern with the Flow team)!
Parser:
- Improved a bunch of "unexpected" parse errors, providing what was expected in the error message.
- Fixed a bug in parsing of params in function types.
Likely to cause new Flow errors:
- Fixed the definition of
Function.prototype.apply
to only accept array-like objects, not any iterable. - Improved error positioning, which may cause previously-suppressed errors to become unsuppressed.
New Features:
non-array-spread
lint rule: Fires when a non-array iterable is spread. This is useful for modeling theloose: true
mode of@babel/plugin-transform-spread
, where such code causes a runtime error.
Notable Bug Fixes:
- Fixed a performance regression when computing dependencies in large projects
- Fixed built-in library definitions that needed to be explicitly inexact to pass the
implicit-inexact-object
linter. - Improved libdefs for many browser APIs (e.g. Media Streams, MIDI, Permissions, Workers) (#7737, #7805, #7806, thanks @goodmind!)
Misc:
- Various improvements to the types-first signature generator
- Improved the name of the server master process in
ps
- Improved the output of
flow check --profile
flow-remove-types
:
- Remove opaque types and
declare export
Parser:
- Fixed a bug allowing
await
to be a parameter in async functions - Several improvements to the experimental comment attachment algorithm
New Features:
- Added
--types
flag toflow cycle
, when given only type dependencies are used to compute cycles
Notable bug fixes:
- Fixed a bug when destructuring unions gave spurious errors [example]
- Updated for-in/for-of head expressions to be evaluated in the correct scope [example]
Performance:
- Improved the calculation for what are dependents of a file, reducing work during rechecks
Library definitions:
- Added support for Array#flatMap (thanks @goodmind)
- Replaced usages of
Object
andFunction
(which are aliases forany
) in library definitions withany
- Removed some usages of
any
from library definitions - Updated Function#apply to accept strictly two arguments (thanks @goodmind)
- Added SpeechSynthesis definitions (thanks @goodmind)
Misc:
- Updated/added HTML spec URLs in comments (thanks @kevinSuttle)
- Fixed parsing of anonymous class implements clause (thanks @goodmind)
- Added support for printing mixins and implements (thanks @goodmind)
Likely to cause new Flow errors:
- Function components with no arguments get a sealed empty object type as props.
- Moved
MixedElement
export into the module declaration, so it will now need to be qualified asReact.MixedElement
.
Notable bug fixes:
- Fixed error positioning around utility types (e.g.
$ObjMap
). - Omit reporting error stack traces to end users over LSP.
- Fixed bug where Flow would crash when variable has same name as a type (fixes #7825)
Misc:
- Refactored coverage computation to use the typed AST. This enables coverage results over more locations that earlier.
- Improved server and monitor error logging.
- In typing object types as react components, account for the
defaultProps
property and make them compatible withReact.AbstractComponent
. - Optimized the way module exports are populated to prevent recursion limiter exceptions.
- Improved error messages for invalid
BigInt
s. (thanks, @goodmind!) - Hovering over an imported type alias returns its definition. (thanks, @vicapow!)
- Fixed semver comparison to allow for suffixes such as
rc
.
Libdefs:
- Remove
Object
type (equivalent toany
) fromWeakSet
and$ReadOnlyWeakSet
. (thanks, @goodmind!) - Add methods to Node HTTP ServerResponse type definition. (thanks, @chrislloyd!)
- Add definitions for the Web Animations API. (thanks, @goodmind!)
Notable bug fixes:
- Fixed a bug with suppressions in the experimental types-first mode.
Likely to cause new Flow errors:
$Keys
now produces a more precise type, which may find errors where incompatible strings were passed to something expecting the$Keys
of some object.
New Features:
- We released a new implicit-inexact-object lint to detect when an inexact object is used without explicitly adding
...
to the end of the props list. See here for context. - Function type parameters may now use default arguments. This is not yet supported by babel.
Notable bug fixes:
- Fixed a bug with ranges returned by autocomplete
- Fixed a bug where errors with bad locations reported over the LSP could cause the editor to clear all errors.
Misc:
React.memo
andReact.lazy
now both allow you to specify an instance type viaReact.AbstractComponent
.- Various performance improvements to union types.
- Various libdef fixes and improvements.
- Various improvements to error positioning.
- The recursion limit is now configurable in the .flowconfig via
recursion_limit
. Most projects will not need to override this value.
Parser:
- Forbid private fields named
#constructor
- Fix duplicate private class field validation for getters/setters
- Fix parsing of private getters and setters
- Function type parameters may now use default arguments.
Likely to cause new Flow errors:
- The
React$ElementType
annotation, which was previously unsafe, is now strict. Before you could create an element given a component with this type using arbitrary props. To annotate any component that accepts some given props, useReact$ComponentType
instead. Try Flow example - The
React$ComponentType
annotation is now strict when used with refs. Before, it was possible to pass aref
having any type when creating an element from a component using this type. If you need to describe components that accept refs, use theReact$AbstractComponent
type instead. Try Flow example - The
$Enum
built-in type annotation is now deprecated. Please use the semantically equivalent$Keys
type instead. - Destructuring patterns could previously include missing properties if the resulting binding was unused. This is now an error even when unused. Try Flow example
New Features:
- You can now use the built-in type
React$MixedElement
as the sound superclass of all React elements. This is a type alias forReact$Element<React$ElementType>
.
Misc:
- Add
decode
method toHTMLImageElement
(thanks, @vicapow!)
Parser:
- Handle NonOctalDecimalIntegerLiteral
- Remove U+180e (Mongolian vowel separator) from list of valid whitespace code points
- Remove support for legacy octal literals with numeric separators
- Remove support for legacy octal bigints
- Fix various issues related to automatic semicolon insertion (ASI) for class properties
Notable bug fixes:
- Fix bug where well-formed-exports errors were reported for unchecked files
Likely to cause new Flow errors:
- The statics of function types used to be
any
but are now typed as an empty object. - Recursive calls of named function expressions were previously unchecked, but are now checked.
$call
property syntax, deprecated in Flow v0.75, has finally been removed.
Notable bug fixes:
- Fix an issue where Flow would not catch certain errors involving React function components with unannotated props.
- Fix React synthetic mouse events for drag, wheel, pointer events to give the specific native event type. (Thanks, @Kiwka!)
Misc:
- Improved performance of starting a server from a saved state.
Parser:
- Fix parsing of function types inside tuples inside arrow function return types.
Notable bug fixes:
- Do not report bad module uses in unchecked files
Likely to cause new Flow errors:
- Infer
void
before typechecking starts for functions without areturn
statement, lessening the impact of a union typechecking bug (#7322). - Fix a bug which prevented Flow from asking for required type annotations.
- Turn the
deprecated-utility
lint on by default. - Two related changes to type refinements to fix unsoundness:
mixed
refined to an array produces a read-only array.mixed
refined to an object produces a read-only object.
New Features:
- Add the ability to exclude paths included by a previous pattern in a
.flowconfig
(#7317).
Notable bug fixes:
- Fix a bug that led IDEs to report all code as uncovered (#7654).
- Fix the
untyped-import
lint rule so thatexport [type] * from
triggers it. - Flow now recognizes refinements against negative number literals.
Misc:
- Exclude
deprecated-utility
anddynamic-export
lints when applying all=setting rules (#7473). - Improve client/server version mismatch behavior so that the newest of the two is preserved, rather than the client version.
- Preserve exactness of the input type when using
$ObjMap
or$ObjMapi
(#7642). - Minor changes to metadata in the results of
flow type-at-pos --json
. - Batch
DidOpen
notifications from the IDE in order to make checking in IDE lazy mode more efficient. - When
flow lsp
automatically starts a server, it prefers the lazy mode set in a.flowconfig
to the lazy mode passed on the CLI. - Allow lints to be explicitly set to their defaults (normally redundant lint settings are disallowed).
- Fix spurious missing annotation errors when the
this
type is used incorrectly. - Fix a bug that made
React.Element
behave differently thanReact$Element
. - Fix an edge case where object property assignments were typechecked incorrectly (#7618).
- Fix an unsoundness with addition or logical operators when combined with generics (#6671, #7070).
- Fix an issue which allowed read-only arrays to be written to if the index was of type
any
. - Fix a bug which stymied typechecking after try/catch blocks (#7530).
Libdefs:
- Add
document.elementsFromPoint()
(#7540). - Add
ConstantSourceNode
(#7543). - Remove
React.Suspense
maxDuration
attribute (#7613).
Likely to cause new Flow errors:
- Refining a variable of type
mixed
withinstanceof A
produces typeA
insteadempty
which was produced before. - Types imported in a
declare module
are no longer automatically exported from that module as well.
New Features:
- #7518 Adds support for LSP function parameter completion (thanks @vicapow)
Notable bug fixes:
- Return a better error message when
flow coverage
is passed an invalid input path. - Fixed a bug in which Flow crashed on very long directory paths.
- Fixed type-at-pos results when reporting the type of a callable object.
Misc:
- Improvements in AST utilities: The differ got improved support in several kinds of type annotations (literals, generic identifiers,
typeof
, tuples and interface types). The mapper got support for qualified identifiers. - Introduces a resizable array data structure that is used in union-find.
- Improved error messages around callable and indexer.
- Type-at-pos now shows results without evaluating type destructors like object spread,
$Diff
, etc. This should lead to more compact results. - Various refactorings in the internal type language and environment.
Library definition improvements:
- Updates in Node definitions. The stream definitions were updated to the latest version, and the readline.createInterface definitions were also updated.
Parser:
- #7471 Adds support for parsing of BigInt (Arbitrary precision integers) (thanks @goodmind)
- Object literals with spreads can be described by object types with spreads in the signature verifier/builder.
Likely to cause new Flow errors:
-
Recently the
Object
andFunction
types changed their meaning from "any function type" to "any type." Accordingly, variousObject
andFunction
annotations that made sense before this change have been updated in various library definitions. -
Various other PRs making improvements in library definitions have been merged in this release. These include core definitions like
Date
andObject
as well as other DOM and Node definitions. -
We now issue a error when a value that is clearly not a type could be exported as such.
-
We now issue an error when a function is imported as a type.
Notable bug fixes:
-
Some commands are not expected to update server state. But if such a command is cancelled and we run a recheck before rerunning the command, not updating the server state would make it seem like that recheck never happened (and lead to spurious future rechecks). This has now been fixed.
-
Fixed node_modules filter for lint warnings, which didn't work on Windows, and didn't respect the node_resolver_dirnames config option.
Misc:
-
Results of
batch-coverage
in lazy mode can be misleading, as it does not account for the fact that the currently checked files might not be the ones the user is querying for. Runningbatch-coverage
in lazy mode is now disallowed. -
Fixed an issue with
flow lsp
where logs would not be flushed.
- The inferred statics object type of
React.createClass({})
will containdefaultProps: void
, instead ofdefaultProps: {||}
(unsealed empty object). - Bug fix in internal cache mechanism
- Added an overload for
JSON.stringify
allowingmixed
input, which returnsstring | void
. Without this, you can't callJSON.stringify
on amixed
value at all, because while Flow does allow refiningmixed
to "not void" (e.g.x === undefined ? undefined : JSON.stringify(x)
), it does not support refiningmixed
to "not a function" (e.g. imagine you could dox === undefined || typeof x == 'function' ? undefined : JSON.stringify(x)
). This rolls back some of the more restrictive behavior introduced in v0.95.0, but is still more restrictive and more accurate than in <= v0.94.0.
Likely to cause new Flow errors:
- Disallow
undefined
and functions inJSON.stringify
:JSON.stringify(undefined)
returnsundefined
instead ofstring
. Rather than make it always returnstring | void
, or use overloads to returnvoid
on those inputs, we instead disallow those inputs since they are rarely the intended behavior. (#7447)
New features:
flow batch-coverage
: A new command to compute aggregate coverage for directories and file lists. Instead of producing the coverage at each location, it sums them and reports the per-file percentage and the aggregate percentage.
Bug fixes:
- Fixed incorrect reporting of signature verification lint errors in unchecked files
Other improvements:
- #7459 Add type for Symbol.prototype.description (thanks @dnalborczyk)
- #7452 Add types for String.prototype.trimStart/trimEnd (thanks @dnalborczyk)
- #7500 The "kind" of an autocomplete result is now reported over the Language Server Protocol, improving the autocomplete UI (thanks @vicapow)
Bug fixes:
- Fixed
dynamic-exports
lint's spurious errors on exported classes and functions - Handle package.json files that are valid JSON but invalid packages
Performance:
- Reduce memory usage by filtering suppressed lint errors before formatting the errors for printing
- Quicker responses to cancellation requests
Many libdef fixes and other improvements from the open source community:
- #3209 Fix autocomplete for generic type aliases (thanks @vkurchatkin!)
- #6750 Remove shadowed generics in
Proxy$traps
(thanks @talbenari1!) - #6000 Document async function return type (thanks @callumlocke!)
- #7448 Tweaks to built-in http module (thanks @STRML!)
- #4570 Update types for Web Audio API (thanks @fand!)
- #5836 Fix examples in libdefs/creation page (thanks @tomasz-sodzawiczny!)
Additional lib def improvements:
- Make
current
write-only inReact.Ref
- allowing union types for ref - Add
setMediaKeys
API to definition ofHTMLMediaElement
- Make type parameter to
http$Agent
covariant
Likely to cause new Flow errors:
- Removed a constraint involving
any
types and React proptypes for efficiency. This may result in some errors no longer being reported.
New Features:
- A new lint (
dynamic-export
) which when enabled will warn when most dynamic types are exported from a file. - Flow now distinguishes between
any
andempty
when computing line coverage.empty
types are colored blue andany
types red when using the--color
option. Note that this may cause new expressions to be considered uncovered.
Notable bug fixes:
- Fixed a non-termination condition during
this
-substitution. - Fixed an issue where
inexact-spread
lint errors could appear in the wrong position.
Many, many libdef fixes and improvements! Many thanks to the open source community for these, and to @nmote and @jbrown215 for reviewing and merging so many of these!
- #4388 add missing
InputEvent(Listener|Handler|Types|)
(thanks @keithamus!) - #4664 Fix
IntersectionObserver
constructor definition (thanks @apostolos!) - #4858 Make
ServiceWorkerMessageEvent
extendExtendableEvent
(thanks @keyiiiii!) - #4772 add indexer property to string lib def (thanks @zacharygolba!)
- #5529 Add
module.builtinModules
to core libdef (thanks @simenB!) - #5574 fix return parameter for
writable.setDefaultEncoding()
(thanks @dnalborczyk!) - #5578 add
util.callbackify
to node type def (thanks @dnalborczyk!) - #5628 Add lib declaration for
BroadcastChannel
(thanks @schmatz!) - #5866 Add definition for
timingSafeEqual()
(thanks @rolftimmermans!) - #5988 add
destroy
method to streams (thanks @hiikezoe!) - #6091 Fix static declarations for
XMLHttpRequest
(thanks @robin-pham!) - #6339 Fix parent of
AnimationEvent
(thanks @ngyikp!) - #6367 Add types for
Object.getOwnPropertyDescriptors
(thanks @disnet!) - #6471 Actualize node's
EventEmitter
API definition (thanks @antongolub!) - #6535 add
Element.prototype.toggleAttribute
(thanks @keithamus!) - #6614 Add
TransitionEvent
to dom libdef (thanks @koddsson!) - #6785 Allow specifying encoding as string in options field of
appendFile
,appendFileSync
(thanks @cappslock!) - #6963 Add Audio declaration (thanks @vldvel!)
- #7011 Use more specific type for
navigator.serviceWorker
(thanks @dhui!) - #7097 Add type definitions for message events (thanks @wachino!)
- #7122 Support for
Uint8Array
(thanks @cakoose!) - #7144 Updated URL modules definitions for Node.js 10 (thanks @MrFranke!)
- #7146 Fix type definition of Node.js
dns.lookup()
(thanks @shuhei!) - #7215 fix
https
interfaces (thanks @cakoose!) - #7225 make
createContextualFragment
return aDocumentFragment
(thanks @wincent!) - #7342 add Document.queryCommandSupported (thanks @Eazymov!)
- #7358 Add
oncontextmenu
toHTMLElement
(thanks @jasonLaster!) - #7363 Add
MediaDeviceInfo
declaration (thanks @ea167!) - #7367 Add
userSelect
to CSS declaration (thanks @shubhodeep9!) - #7368 Fix
fs.promises.readFile
being incorreclty overloaded (thanks @Macil!) - #7381 add
EventSource
to dom libdef. Likely to cause new errors (thanks @SlIdE42!) - #7386 fix
XDomainRequest
in bom libdef. Likely to cause new errors (thanks @Mouvedia!) - #7387 Added optional
displayName
property toReact$Context
(thanks @bvaughn!) - #7405 Basic support for
typeof x === 'symbol'
(thanks @mroch!) - #7420, #7430 and #7440 Various React improvements (thanks @threepointone!)
- #7423 make
useRef
type non-nullable (thanks @trysound!) - #7445 add
Stream
type to Node thanks (thanks @goodmind!)
Misc:
- Updated our website and GitHub issue template to make it easier for open source users to contribute to Flow!
- Various improvements to the AST, including the differ, typed AST and the AST mapper
Notable bug fixes:
- Fixed a bug introduced in v0.92.0 which could cause the server to crash when using an IDE.
- Fixed
module.system.haste.name_reducers
option for Windows (#7419 - thanks jamesisaac)
Likely to cause new Flow errors:
Some fixes to tagged template literals will surface a new set of pre-existing errors!
New Features:
This release culminates months of hard work on quality of life improvements for IDE support. Expect your requests to be faster, and your requests to take a bit less time.
- Several Flow commands can run in parallel now, i.e. you can still get type definitions while rechecking. Big props to @glevi for this massive QoL improvement!
- Alongside this change, @glevi also released a new lazy-check mode that leverages
watchman
to reduce the number of checked files. Learn about it in the docs.
Notable bug fixes:
Thank you to the opensource community for these fixes!
- #7354 Fix MouseEvent type definitions
- #7262 Update types for WeakMap
- #7100 Add missing crypto.randomFillSync and crypto.randomFill methods
- #7356 Add definitions for new debug hook useDebugValue
- #7352 Rename React hook useImperativeMethods -> useImperativeHandle
- #5665 Fix arity of clearInterval, clearTimeout
React.memo
now accepts any kind ofComponent
Likely to cause new Flow errors:
- Better positioning for React error messages. This may move already existing (and suppressed) errors to new positions.
New Features:
- The
--lazy-mode
flag was added to all commands that may autostart a server
Notable bug fixes:
- Fix a crash when using private class fields (fixes facebook#7355)
Misc:
- Various additions and typo fixes on flow.org docs and README (thanks @fschindler, @dominicfraser, @keithamus, and @fterh)
- Misc OCaml tweaks (thanks @rvantonder)
- Huge reduction (~15%) in total memory usage (thanks @nmote)
- Huge reduction in error collation time (thanks @panagosg7)
Likely to cause new Flow errors:
- Removed unsafe rule allowing Date instances to be used as a number
- Changed $Shape<> types to reject null and void as subtypes
- Removed unsafe refinement from mixed to a function type using typeof
Pull Requests:
- #7290 Add support for Path2D constructor arguments (thanks @zpao!)
- #7221 use package that works with 7.x in babel doc (thanks @rob2d!)
- #7231 Improve type of 'mkdir' and 'mkdirSync' (thanks @mrtnzlml!)
- #7278 fix: update toc links in hoc pages (thanks @evenchange4!)
Notable bug fixes:
- Fixed issue where errors involving $Shape<> types were positioned poorly
Parser:
- Fixed decoding of html entities at beginning of JSX children
- Fixed offset calculation in estree output to account for multibyte characters
Likely to cause new Flow errors:
- Big revamp to React typing with the goal of adding support for
React.forwardRef
and better typing higher-order components. Docs are available here.
New Features:
- New
deprecated-utility
lint complains about deprecated Flow types. To start off,$Supertype
and$Subtype
are now deprecated. They were unsound and can usually be replaced using shapes or bounded generics. React.AbstractComponent
makes it way easier to type React higher-order components.React.Config
is also intended to help type React higher-order components.
Notable bug fixes:
flow coverage --color
handles multi-byte characters betterflow coverage
now supports--strip-root
Misc:
- We've deleted
flow gen-flow-files
due to bitrot. We do plan on building a better version in the future. - Various libdef updates. Thanks for all the PRs!
{}
now consistently represents an unsealed object. You can read more in the documentation. example
Likely to cause new Flow errors:
- Made
Function
andObject
types be aliases forany
. They were always unsafe types, just likeany
, but they had peculiar behavior. This change revealed places where they were handled improperly within Flow, and ended up surfacing type errors that were previously missed.
New Features:
- Added the experimental Watchman lazy mode (
flow start --lazy-mode watchman
). This improves the lazy mode experience for repositories which use Mercurial and Watchman. We will document it more when/if it proves itself. - Added
flow config check
which validates the.flowconfig
.
Misc:
- Made miscellaneous improvements to the AST differ, which improves the output of global rename.
- Made
.flowconfig
parsing less strict (in particular, if the--ignore-version
flag is passed, do not fatal on unrecognized config options). - Performed a code cleanup in type normalization that caused some types in
type-at-pos
to be displayed differently. - Removed redundant information in stored ASTs resulting in a modest reduction in memory usage.
- Flow assigns long string literals type
string
, rather than the singleton type of that literal. Now, this fact is surfaced in error messages. - Fixed stack overflows:
- When checking a large number of files.
- When a large number of errors are present.
Libdefs:
- Added
React.Suspense
. - Removed
React.useMutationEffect
hook.
Likely to cause new Flow errors:
- Fixed an error in the
React.createRef
definition. Refs are for any type of value, not just React elements.
New Features:
- Added support for subcommands to the CLI and a
flow config find
command that finds the .flowconfig governing path.
Notable bug fixes:
- Fixed file_sig for deep destructured requires.
- Fixed a stack overflow in the
flow ls --json
command. - Fixed a crash when the module reference prefix is used on an untyped module.
Misc:
- Removed the
flow port
command. - Various improvements to the AST differ.
- Made progress in shifting from concrete to abstracting locations, by
- functorizing a number of modules over their use of locations, and
- updating the core typechecking logic to operate solely on structures containing abstract locations.
- Removed the redundant Expression.Member.computed field from the AST.
- Allow configuring path to node in runtests.sh.
- Refactored
JSX.frag_closingElement
of the AST to not be an option. - Fixed error localization in
import type
andimport typeof
with default. - Added the location of function signatures to the AST.
- Removed prototype members when autocompleting JSX props.
- Cleaned-up handling of the mixed case from LookupT.
- Optimized the case of enumerations when used as keys.
Library definition changes:
- Made geolocation
PositionOptions
optional. - Added flow definitions for React hooks.
- Added a
calculateChangedBits
parameter to theReact.createContext
definition. - Added
React.ConcurrentMode
andReact.StrictMode
definitions. - Added
React.lazy
andReact.memo
definitions.
Parser:
- Refactored flowconfig option parsing into a list of parsers.
Likely to cause new Flow errors:
- New errors may arise from generic definitions which lack the necessary annotations. Flow does not infer generic types, and the types it used to infer in their place occasionally masked errors. The types it now infers are still not generic, but will mask fewer errors.
- Fixed bug in union type checking which caused Flow to miss some errors when used in conjunction with generics and certain utility types.
- Improvements to constraints involving
any
may result in new errors.
New Features:
type-at-pos
can reconstruct spread objects when evaluation of the spread is not possible.type-at-pos
now supports implicit instantiation with_
.- Added core types
$ReadOnlyMap
,$ReadOnlyWeakMap
,$ReadOnlySet
, and$ReadOnlyWeakSet
. These types and their mutable counterparts mostly follow the pattern of$ReadOnlyArray
andArray
: the read-only parent class provides non-mutating methods, and the usual mutable class extends it. Unlike$ReadOnlyArray
, the new types are invariant in their type parameters. - Added the
React.StrictMode
type. - Added the
flowtest
package.flowtest
is a CLI tool for running tests on Flow types. - Added the
sharedmemory.heap_size
option.
Notable bug fixes:
- Restructured file signatures to support overloading in exports.
- Allow named exports in exact
module.exports
objects. - Fixed forward references for
declare function
. - Various bug fixes to the type normalizer and to
type-at-pos
. flow suggest
no longer outputs<<anonymous class>>
.- Imported symbols should no longer appear
Remote
intype-at-pos
.
Misc:
- Improved formatting in JavaScript output.
- Improved the way the element type of an array is determined.
- Various improvements to the AST differ.
WeakMap
keys must now be objects.- Improved profiling for error collation and formatting.
- When a union lower bound flows into a union upper bound, if both unions are enums, we use the underlying set representation to handle this in O(n log n) time instead of quadratic time.
- The type normalizer properly represents utility types instead of treating them as generics.
- The type normalizer provides more accurate information about generics.
- Flowing a string lower bound into a union upper bound occurs in O(log n) instead of O(n) when the union is an enum.
- CJS modules' namespace objects are now treated as covariant.
- The type normalizer reconstructs literal types more precisely when
preserve_inferred_literal_types
is set. This does not change the behavior oftype-at-pos
. - Deleted the
experimental.cancelable_rechecks
option.
Parser:
- Removed the deprecated
expression
field fromFunction
nodes in the AST. - Enabled some tail call optimizations in
flow_parser.js
which should cause it to stack overflow in fewer cases. - The layout generator no longer prints empty statements as
{}
instead of;
in pretty mode. - Allow anonymous function parameter types inside generics inside arrow function return types. For example, we disallow
var x = (): (string) => number => 123
because the first=>
is ambiguous. However,var x = (): T<(string) => number> => 123
is not ambiguous and we no longer disallow it.
Likely to cause new Flow errors:
-
Fixed an issue that caused missing annotations errors to be suppressed.
Please read the full post for more information on what changed and tips on dealing with the new errors.
Likely to cause new Flow errors:
- Earlier, type constraints between
any
and other types would be dropped. Instead, they are now propagated. In some cases, this unblocks further constraint solving and helps find more errors. - When a variable is equality-checked with a literal, the variable's type is refined. Earlier, if
the variable's type was incompatible with the literal's type, it would silently be refined to
empty
, whereas now this is an error.
New Features:
- Added support for wildcard (
_
) type arguments to function / constructor calls. This is especially useful when some type arguments are sufficient to pin down the type of the result; the others can simply be_
.
Notable bug fixes:
- Fixed a case that would crash
get-def
andfind-refs
- Fixed a bug with unreachability analysis for ternary expressions
- Fixed a bug with refinements merging at the end of switch statements
Misc:
- Fixed various AST printing / layout bugs
- Made various improvements to the AST differ
- Refactored parts of
get-def
andfind-refs
to reuse code - Made progress on abstracting locations in the core type inference engine
- Made progress on module signature verification and generation
- Merged PRs that improve type declarations: e.g.,
getBoundingClient
returns aDOMRect
instead of aClientRect
.
Parser:
- Support for
...
to indicate inexactness in object types
Likely to cause new Flow errors:
- Fixed a bug where type precision was lost at module boundaries
Notable bug fixes:
- Prevented an exponential blowup when union types flow into "maybe" (
?T
) or "optional" (essentiallyT | void
) types - Allowed
{p:T}
to be a subtype of$Shape<{+p:T}>
Misc:
- Fixed exception when using --traces
- Changed
--verbose
to not log while loading flowlibs by default; pass--verbose-flowlibs
to override - Added ability for LSP clients to cancel previously-sent commands
- Improved location of diagnostics via LSP while typing
- Fixed LSP textDocument/definition response when there are no results (prevents bogus jump-to-definition inside comments, for example)
- Limited number of errors returned via LSP to 200, to improve Nuclide and Visual Studio performance
- Fixed an exception when attempting to focus a file that Flow ignored
Library definition changes:
- Added
ResizeObserver
declarations - Added missing
net$Server.listening
property - Added
process.cpuUsage()
Parser:
- Fixed
export default async function
to be aFunctionDeclaration
not aFunctionExpression
- Made instance properties named 'constructor' a syntax error
Likely to cause new Flow errors:
- Removed the ability to use functions as type annotations. This ability was originally designed to support ES3-style classes, but in practice causes confusion and missed errors. We found that the vast majority of added errors were detecting legitimate bugs, and the remainder could be easily updated to ES6 classes.
New Features:
- Added worker utilization and GC profiling under the
--profile
mode.
Misc:
- Further improved performance of IDE requests on large codebases.
- Tweaked OCaml GC settings to reduce time spent collecting on workers.
- Improved performance and reliability of watchman integration.
Likely to cause new Flow errors:
- Fixed a bug which allowed refinements to incorrectly escape outside of conditional expressions.
- Plugged a hole which incorrectly allowed
this
to appear in a constructor before asuper
call in some cases. - Some errors related to uses of
typeof
may be reported at a different location than they previously were. - Disallowed shadowing class methods with incompatible properties of the same name.
- Made miscellaneous other bug fixes that manifest only in rare cases.
- Made module properties covariant, meaning that e.g. mutating properties on the object returned by
require()
is not allowed.
Notable bug fixes:
- Improved performance of IDE requests (e.g. autocomplete, get-def) on large codebases roughly 3x.
Misc:
- Made a number of improvements to the diffs generated by global rename.
- Changed how saved-states are loaded.
- Added additional information to error messages for missing annotations for type parameters.
- Disallowed class static properties named
prototype
orconstructor
.
Library definition changes:
- Added type definitions for pointer events.
- Updated DOM
scrollIntoView
to match latest spec. - Updated
String.prototype.toLocaleLowerCase
andtoLocaleUpperCase
to allow optionallocale
parameter. - Made
Object.prototype.valueOf
returnmixed
instead ofObject
. - Removed the indexer from the
Object
libdef. - Updated
TextDecoder
to properly accept aBufferSource
. - Added
MediaStreamTrackEvent
definition. - Made
String.match
returnRegExp$matchResult
. - Added additional constants to the
fs
module.
Likely to cause new Flow errors:
- We've changed how Flow lint severity is calculated. We used to look at every location mentioned by a lint and we'd use the lowest severity, where Off < Warn < Error. Now we just use the severity at the lint's first location. Flow suppression comments (e.g.
// $FlowFixMe
) can still suppress a lint at any mentioned location. Depending on your setup, this change may expose Flow lints which were turned off by accident. For example, a "Sketchy Null Check" lint in a file with that lint set to error would have been turned off if it also mentions a file with that lint off. Now that lint will show up as an error. - Some libdef changes may cause a few errors. For example,
Headers.get
andURLSearchParams.get
are now annotated to returnnull | string
instead ofstring
andFile.lastModifiedDate: any
was replaced withFile.lastModified: number
.
Notable bug fixes:
- Fixed a crash that could happen when a persistent connection disappears.
Misc:
- Many improvements to the libdefs and docs. Thanks for the PRs, everyone!
- Small perf improvement by making
BoundT
(internal representation of type parameter bounds) smaller.
Parser:
- Small change to the OCaml AST for the
extends
expression in a class declaration. Moved a couple of properties to their own node.
Notable bug fixes:
- If a server was not already started, running
flow status --flowconfig-name 'name'
would start a server without taking into account the new flowconfig name. The same is true for running flow without any command specified. This changes this by passing the name to the new server.
Likely to cause new Flow errors:
- A fix in requiring annotations on exports: Flow uses type variables for unannotated program parts. To facilitate inference, these type variables may not appear in input positions of exports. Before, Flow would not complain if a type variable appeared in both an output and an input position of an export (in that order), as the first occurrence marked the use of the type variable as legitimate. Now, Flow analyzes exports in a polarity-sensitive way and will require an annotation in the above scenario.
New Features:
- Saved state:
- Added an initialization path, where instead of parsing every file dependency, it loads the expected results for each available file from the saved state.
- A hash is stored for each file in the saved state to determine whether it has been modified and therefore needs to be reparsed after the state is loaded. This way, saved state servers can skip parsing files that are unchanged.
- If loading saved state fails, Flow falls back to a full initialization, unless
--saved-state-no-fallback
is passed in which case Flow fails. - Saved state tests are included in the automated testing framework.
- Profiling was refactored to support hierarchical profiling. That is:
- Support running timers inside of other timers.
- Support merging a finished profiling object (like from a recheck) into the currently running profiling object (like from handling a command).
- Cancelable workloads (jobs that handle commands). If Flow determines that a file has changed while handling a command, it stops, performs a recheck, and then re-runs the workload from scratch.
- The Flow diff checker became more fine-grained, by including comparisons at the level of loops and variable declarations.
- Added a
name
field in the[options]
portion of.flowconfig
.
Notable bug fixes:
- Send the server logging context to the LSP command and use that when logging success and failure events instead of the LSP command's context (which is logged as the client context).
- Fixed stack overflow when running
flow --json
with a large error output, by moving to a tail-recursive implementation. - Fixed string literal printing in
flow suggest
.
Misc:
- Library definition improvements for
React$Context.Provider
andCanvasRenderingContext2D.imageSmoothingQuality
. - Typed AST: The constraint generation phase returns a version of the AST that includes a type for each program node.
- Added doc details for
$Shape
. - The changes in saved state were followed by code refactorings in various checking
modules (
types_js.ml
,merge_service.ml
,rechecker.ml
, etc.).
New Features:
- Added the
unnecessary-invariant
lint, which will flag uses ofinvariant
when Flow can determine that the predicate must be truthy. find-refs
now traverses union types.- The
--flowconfig-name
flag now allows you to specify the name of the flowconfig. - Added a
file_watcher
option for.flowconfig
. - Rechecks will now stop and restart as soon as Flow notices other file changes. The previous behavior was to finish the recheck and then start a new recheck. The new behavior is currently off by default and can be enabled by setting
experimental.cancelable_rechecks=true
in.flowconfig
. Note: This feature is experimental. When it stabilizes, the flag will be removed and this feature will be enabled by default.
Notable bug fixes:
flow-upgrade
should no longer triggerENOENT
on Windows.- Running Flow with
--profile
should no longer throw on Windows. - Suppression comments preceding lint errors for disabled lints should now be correctly considered unused and trigger unused suppression warnings.
ArrayBuffer
's static indexer property is now correctly marked covariant. This should prevent errors like this one.- Fixed a bug in which the polarity of a type parameter was propagated to all subsequent type parameters, causing errors when covariant type parameters followed contravariant or invariant ones. This bug is demonstrated by the difference in behavior of the following examples:
Misc:
- Flow now prints array types as
Array<T>
instead ofT[]
in JavaScript output. - Flow now prints
{foo:x}
as{ foo: x }
in JavaScript output, as Prettier does. - Library definition changes:
- Added
destroyed
tonet$Socket
. - Added
document.scrollingElement
. - Added
dgram$Socket$rinfo
to the Node library definitions. - Added WebAssembly library definitions.
- Added the
groups
property toRegExp$matchResult
.
- Added
New Features:
- New lint to disallow
a && b
whena
is anumber
. See https://flow.org/en/docs/linting/rule-reference/#toc-sketchy-number - Support multi-hop/indirect find-refs in LSP
- Expose renaming through the Flow LSP
Notable bug fixes:
- Fix server crash on persistent-command unhandled exception
Misc:
- Library type definition changes: created explicit type for
Context
, addedreadAsBinaryString
toFileReader
- AST differ utility to power rename
- More uniform bucketing of jobs to be run in parallel leads to higher CPU utilization
- Improvements to type printing
- Treat getters and setters as proto fields
Parser:
- Optimization when saving comments
Likely to cause new Flow errors:
- Flow now only allows subtyping polymorphic types with the same number of type parameters. This added strictness lets Flow avoid some slow typing code and shouldn't cause too many problems.
New Features:
- New
[declarations]
section in the.flowconfig
which can suppress all errors in 1 or more files. Thanks @LegNeato! (#4916) - Added
flow server --file-watcher watchman
flag which uses Watchman for file watching instead of the builtin file-watcher, dfind - Added a
--expand-type-aliases
flag totype-at-pos
. It replaces type aliases with their bodies in the returned type. - Added
flow save-state
command to generate a saved state file (experimental & loading a saved state isn't ready yet)
Notable bug fixes:
- Fixed
type-at-pos
forB
inimport type { A as B } from 'M';
- Fixed
find-refs
,autocomplete
,get-def
, etc for$Facebookism$Idx
Misc:
- Bunch of improvements to the libdefs. Thanks everyone for the PRs!
- Handful of improvements to the type normalizer, which improves the
type-at-pos
output - Tweaked error messages for
+
operator to match other binary operators
Likely to cause new Flow errors:
- Added return type to RegExp.prototype.match() (thanks @peter-leonov!)
- Fixed callable property lookup rules to no longer walk the prototype chain
- Made it an error to import a type via destructuring on a
require
call (useimport type
instead) - Made the type of
Array.of
stricter (thanks @wchargin!)
New Features:
- Added typing rules to support
{| |}
as a subtype of{ +p?: T }
- Added support for optional catch bindings (thanks @cpojer!)
- Improved performance of enum equality checks
- Added support for
[[call]]
syntax in objects and interfaces - Many improvements to
flow find-refs
command - Many improvements to LSP support
Notable bug fixes:
- Fixed crash when refining a non-value
Misc:
- Updated node.js libdefs (thanks @hcz!)
- Fixed some flakiness in the LSP tests
- Added libdefs for ECDH class (thanks @eleith!)
- Added
--check
flag toflow ast
command - Added
filter
property toCanvasRenderingContext2D
libdef - Added
timingSafeEqual
method to node crypto module (thanks @n-johnson!)
Parser:
- Added
Decorator
node, matching estree
Likely to cause new Flow errors:
- Flow now performs exactness checks that were previously skipped in some cases (e.g when
$ObjMap
is used on an exact type).
New Features:
- Significant progress towards supporting the LSP (Language Server Protocol) natively.
- Allow custom module resolvers (experimental, only works with the haste resolver system).
- Flow lints for unnecessary optional chaining.
Notable bug fixes:
- Allow autocomplete to work with optional chaining.
- Only report status as GCing when actually GCing.
Misc:
- Improve the args used when launching child processes to give more information about the process when you run
ps
. - Add a
max_literal_length
option to.flowconfig
which replaces a magic constant. - Multi-hop (indirect)
find-refs
now supports class instances. - Revamp
find-refs
on ES6 named exports to improve reliability. - Allow internal slot properties to be optional.
- Improve shutdown of the server monitor process.
- Try to gracefully stop server process when monitor exits.
- Print server status updates on new lines when Flow is not called from a tty.
- Add additional properties to the
react-dom/server
libdef. - Add 'as' property to the HTMLLinkElement libdef.
- Add a libdef for the Asynchronous Clipboard API.
- Update libdef for
Clients.matchAll
to return anArray
rather than anIterator
.
Parser:
- Rename InterfaceType to InterfaceTypeAnnotation.
Likely to cause new Flow errors:
New Features:
- Inline interface types (
var foo: interface { x: string } = bar;
). Will be particularly useful in the future when we revamp object types
Notable bug fixes:
flow find-refs
threw an exception when used with an unchecked file. Now it treats the file as if it were checked, like other single-file commands doflow type-at-pos
now returns the class name fordeclare class
declarations.
Misc:
- Added
.mjs
to the list of extensions that Flow reads by default - Perf improvements to calculating the dependency graph during recheck. Should help recheck perf on large repositories.
flow find-refs --multi-hop
now parallelizes the work and is much faster- Support using
flow find-refs
andflow get-def
with destructuring patterns as a starting location - Support using
flow find-refs
withdefault
(as inexport default ...
) as a starting location - Bunch of small fixes where
flow find-refs
would miss certain locations - Tweaked the location returned for
flow get-def
when used for default and named imports - Lots of libdef updates. Thanks for the PRs!
Parser:
- Inline interface type support
Likely to cause new Flow errors:
- We've made explicit the order in which imports are merged into a module during typechecking. This fixes an edge case in which lazy modes and non-lazy modes would report different errors. This may change the order in which code is typechecked, and therefore may expose errors that Flow previously missed.
- Treat
$Exact<empty>
asempty
. Before,({p:0}:$Exact<empty>)
was not an error due to missing ground subtyping and decomposition cases. It is now an error. - The
$Either<T>
,$All<T>
and$Type<T>
types are not supported any more.
New Features:
- Find-refs now includes references to all types related to an object literal through subtyping,
and a
multi-hop
mode was added that determines when object types are related through subtyping and links them. - Work towards the new object model:
- Ensure fields overwrite methods in interface definitions (since properties there are flat).
- Store proto fields in a separate map than the one used for own properties in classes.
- Declare
Function.prototype.bind
as a proto field.
- New/call can now be passed explicit type arguments for polymorphic instantiation. Currently this is supported by the Flow parser. Babylon support does not exist, but it is planned.
- Made
*
a deprecated type, under thedeprecated-type
strict flag. - Added support for hover, completion and error reporting (publishDiagnostics) to flow LSP.
- Implemented nullish coalescing as per the TC39 proposal.
- Added a debug flag
--expand-json-output
to print an extended JSON output fortype-at-pos
. - Updates in typings:
- Added the definition for
onclose
to theIDBDatabase
interface inlib/indexeddb.js
(reference). - Added
onmessageerror
toWorker
interface and fixed type ofMessagePort.onmessage
inlib/bom.js
. - Added a
swap64()
to theBuffer
type and aBuffer
property inlib/node.js
. - Added
Intl
objects for the built-in JS language API (ECMA-402 - Internationalization API). - Added tuple types to WebGL
uniform**v
setters inlib/dom.js
.
- Added the definition for
Notable bug fixes:
- LSP: Fixed races in reporting exit status over persistent connection and in test.
- Fixed error reporting when accessing statics and simplified error localization.
Misc:
- Added documentation for
Object
type, "Flow for Atom IDE" in Atom plugins, Flow Strict and thenonstrict-import
lint rule. - LSP supports file edits. Each client now stores the content of files that are opened.
- Added LSP test checking that contents of open files persist after restart.
- Removed Travis from CIs.
- Type normalizer: added option to flag cases where the inferred type parameter is shadowed by another parameter with the same name, and fixed support for recursive polymorphic types.
- Removed dependency on ocp-build (windows now uses
ocamlbuild
). - Introduced a union-find/disjoint-set data structure used in find-refs to maintain sets of related types.
- Fixed return types for
WebGLRenderingContext#is*
methods to all return booleans. - Rearranged contents of
src/server
directory. - Refactored find-refs by splitting variable and property handling in separate files, and breaking down functions based on their purpose (e.g. local vs global).
- Made
$Subtype
and$Supertype
"unclear" types when not in a library context. type-at-pos
now prints types at the client-side.- Minimum OCaml version is increased to 4.05.0.
- Avoid redundant substitution by caching the result of substituting a polymorphic definition with a list of type args.
Parser:
- Added support for nullish coalescing
??
(as above). - Simplified object type parsing. Dangling
+
orstatic
inside an object type (e.g.{+}
) are now disallowed. - Added support for a
proto
modifier in declare class, to specify that the property is a prototype property instead of a class one. - Internal slot properties in object types (e.g.
[[new]]
). - Explicit type arguments in new and call expressions, e.g.,
f<T>(x)
. - Allow reserved words as optional chain property names.
Likely to cause new Flow errors:
- The result of the unary minus (negation) operator would sometimes be incorrectly generalized to
number
rather than a literal type. This has been fixed. - Further restrictions on
module
andexports
. The disallowed patterns include computed property accesses as well as clobbering or aliasingmodule
and/orexports
.- These restrictions are only enabled if
experimental.well_formed_exports=true
is specified in.flowconfig
.
- These restrictions are only enabled if
New Features:
Fragment
has been added to the default exports of theReact
libdef.- Invoking
find-refs
on a property key in a type declaration will now also yield that key in object literals. - Files can now be marked
@flow strict-local
. This mode is the same as@flow strict
, except it does not require dependencies to also be strict.@flow strict
is still the recommended mode, but@flow strict-local
allows enabling strict checking for files before all dependencies can be made strict. Once all the dependencies are strict, a@flow strict-local
file can be upgraded to a@flow strict
file. A@flow strict
file cannot depend on a@flow strict-local
file. - Type support for the Stage 1
Optional Chaining proposal. To use this
feature, set
esproposal.optional_chaining=enable
in your.flowconfig
.- Note: We currently disallow calls whose callees are member expressions when the call or member is part of an optional chain. This restriction will be lifted in the future when we reconcile the optional chaining implementation with our implementation of method calls.
Notable bug fixes:
- The type normalizer now correctly tracks the scope of type parameters instead of assuming they share the scope of the type definition.
- Test output files are cleared before running tests. This prevents old errors from being printed on subsequent failing runs when those runs do not produce errors.
estree_translator
properly handles all cases of theDeclareClass
AST node.- The
suggest
command has been fixed to work with the new type normalizer. - When evaluating spreads inside array literals, we determine the element type early, preventing exponential complexity and infinite loops.
- Object spread in JSX props now preserves exactness.
Misc:
- Various improvements to
find-refs
. - Optimizations for polymorphic subtyping.
- Adds CircleCI for continuous integration and migrates the flow.org build from Travis to Circle.
- New tests for LSP support (disabled by default).
- Certain exceptions will now print backtraces in addition to the exception string.
- Improvements to spreading in array literals.
- Support for Flow coverage reports using codecov.io.
Parser:
- The AST has been updated to use snake_case for record fields rather than camelCase. Some field names have also been updated.
- Support has been added for the Numeric Separators proposal, currently Stage 3.
- The AST representation for Optional Chaining
has been updated to use new
OptionalMember
andOptionalCall
nodes instead of the existingMember
andCall
nodes, and parentheses now correctly limit the scope of short-circuiting. This reflects the current Babel implementation.
Likely to cause new Flow errors:
- Existing
Promise
libdefs for the cases wherenull
orvoid
is passed as callbacks tothen
andcatch
caused us to miss type errors. These libdefs have now been made stricter. - Spreading an object of exact type used to result in an unsealed object type, which allowed adding new properties not mentioned in the original type. Now, the result has an exact object type, which bans adding new properties.
- New missing annotation errors might be reported. These requirements were missed before because of
implementation bugs. We now use the polarity-sensitive type visitor to walk exported types, which
reports errors in the expected places. There are several exceptions, which can be exported without
annotations: e.g., object and array literals; initialized class properties (instance & static);
and
this
parameters. - Interactions of
typeof
with speculative typechecking would lead to missed errors, which will now be reported as expected. - Various new restrictions now ban abuses of
module
andexports
.
API changes:
- The output format with
--json-version 2
includes a breaking change, affecting the "context" property in every location. Previously it was just the first line of the context, which made printing multi-line errors tricky. Now it includes up to 5 lines of context. - New version of ocaml-sourcemaps. The API changed slightly, but most of the changes are adding support for reading/composing sourcemaps, which we aren't using.
New Features:
- Updated React libdefs with the new
createContext
andcreateRef
APIs introduced in React 16.3. - Classes can now be spread (copying over their static properties).
Notable bug fixes:
- Lazy_mode_utils.focus_and_check wasn't filtering out files properly when processing updates.
- The monitor would keep restarting segfaulting servers.
- Lint errors would interfere with speculative typechecking (with union / intersection types)
- Switch to using nonblocking file descriptors with Lwt to address Flow hangs
- Fixed a crash in the no-color error printer caused by degenerate locations.
- Improved refinement of truthy/falsy intersections.
Misc:
- Various improvements to
type-at-pos
and friends, including converting normalized types back to AST nodes for printing. - Various improvements to
find-refs
. - Various CI improvements as part of the move to Circle.
- Various debugging utils.
- Array types are now printed as
Array<T>
instead ofT[]
.
Parser:
- Exposed
implements
andmixins
fields of theDeclareClass
AST node. - Added
tokens
option to JS API:flow.parse(..., { tokens: true })
will now return the token stream, likeflow ast --tokens
does. - Added options support to the parser's C interface. This change lets you pass a map of options to the parser via the C++ API, and from JS via flow-parser-bin. You could already do this from the js_of_ocaml parser, so now their APIs match.
Notable bug fixes:
- Fixed a couple bugs in pretty printing errors which could cause
flow status
to throw an exception
Misc:
- Lots of internal refactoring/changes this release, so not too much to report!
- A bunch of libdef improvements. Thanks everyone for the PRs!
Likely to cause new Flow errors:
Previously, Flow would allow you to write if (foo.unknownProp) { ... }
.
Now Flow disallows testing unknown properties in conditionals. If foo
is a
union type like { x: string } | { y: number }
, x
and y
are known
properties and z
would be an unknown property
New Features:
- Improve union optimizations
- Add type declarations for new React 16.3 lifecycle methods
Notable bug fixes:
- Fix get-def for declare var
- Fix type-at-pos for opaque types
Misc:
- Remove special-casing of
declare var exports
, long deprecated
Restore accidentally-deleted Object.setPrototypeOf library definition.
Likely to cause new Flow errors:
- Replace some
any
-typed API definitions with actual types. This may cause errors in code that uses those APIs.
New Features:
find-refs
now has support for object type properties.
Notable bug fixes:
find-refs
can now find identifiers used as JSX component classes (e.g.<Foo/>
).- Fix nontermination that could occur when printing types (e.g. for
type-at-pos
).
Misc:
- Fix
type-at-pos
on method calls that have been affected by type refinements. - Add
--profile
flag toflow force-recheck
. - Fix
--retry-if-init false
. - Improve
type-at-pos
location for opaque type declarations. - Add a message to the
flow status
output when the server is in lazy mode. - Include filename in flow ast output.
- Add typings for
ReactDOM.hydrate()
. - Make
process.umask
's argument optional. - Some miscellaneous improvements to code quality.
Parser:
- Optional chaining parser support. This feature does not yet have type system support and should not be used.
- Error message redesign to help you better debug typing issues in your programs.
- Upgrade global
find-refs
from experimental to beta. - Improve global
find-refs
performance by 2x-20x depending on the workload. - Support for CommonJS imports/exports with global
find-refs
. - Find usages of overridden instance methods with
find-refs
. - Improvements to type reporting services like
type-at-pos
andcoverage
thanks to a type "normalizer" rewrite. Notably, the normalizer and client services liketype-at-pos
now:- Make more aggressive use of type aliases, leading to more compact results,
- Correctly distinguish between class types and their instance counterparts,
- Report abstract type parameters themselves instead of their bounds, and
- Precisely report recursive types.
- Unresolved type variables internally unified with
any
no longer completely resolve toany
. This may uncover new bugs in your programs where some inferred types silently resolved toany
. - Fix type system "stall" for spreads of null and undefined. This meant programs like
({...null}: {p: number});
incorrectly passed Flow. If you were spreading a maybe-object type then Flow may catch some new bugs in your programs. - Because of the new error messages some suppression comments (configured with
suppress_comment
) will become unused since error locations moved.
- 3.5x performance improvement for some Facebook projects that makes heavy use of complicated unions of string literals such as GraphQL enums generated by Relay. (Performance improvements will scale with your usage of large string literal unions.)
- Improve the
nonstrict-import
lint's error message. - Fix bug in
React.cloneElement
for stateless functional components. - Add
--max-warnings
flag which allows Flow to exit with a non-zero exit code if warnings are present. - Add
--file-watcher
flag to ignore file system events. - Expose
url.format
'surlObj
argument type.
Likely to cause new Flow errors:
-
Improved inference of
const
bindings (let
s andvar
s that are never reassigned), and introduced similar inference for function params. This allows Flow to be less pessimistic about refinements, especially inside closures. For example:function f(val) { if (val == null) return () => 42; return () => val; // OK, since val cannot be null }
- Fixed regression in recheck performance
implements
now works ondeclare class
in addition toclass
declare module
library definitions are now considered@flow strict
- Fixed non-
@flow strict
import rule when in a cycle - Fixed incorrect spreading call properties and indexer properties from interface types
- Fixed
type-at-pos
andcoverage
commands when they encounterObject.prototype
andFunction.prototype
- Fixed a crash when hit with more than 1024 concurrent connections, by returning an error instead
- Fixed the --timeout flag to work properly now that it connects instantly to the server monitor
- Added an exit code (5) for when the server goes unused for a week and shuts itself down
- Added a
merge_timeout
.flowconfig option to mirror the--merge-timeout
CLI flag added in 0.64
- Fixed location of types containing trailing parens
- Added
implements
toDeclareClass
nodes
Likely to cause new Flow errors:
event
is no longer recognized as a pre-declared global
Notable bug fixes:
- An optimization intended to reduce redundant work during rechecks never fired after recent changes.
- The implementation of React.ElementConfig involved a subtyping rule going the wrong way.
Performance improvements:
- Typing info for files were retained in memory even after those files were deleted. This memory is now reclaimed.
- Dependency calculations that occur during initialization and every recheck are now faster.
Misc:
- Adds --merge-timeout server flag
- Drops non-strict type args config
- Fixes issue where flow-upgrade would not check .jsx files
- Includes various fixes to docs
Parser:
- Includes thin bindings to allow interfacing with the parser from C++. A prebuilt libflowparser.a is available for Mac and Linux on the GitHub release.
- flow-parser-bin is an experimental node.js extension that provides access to the native (OCaml) parser from JS. flow-parser will be updated to delegate to flow-parser-bin if your platform supports it, and fall back on the slower compiled-to-JS implementation otherwise.
- Trailing commas after a rest element in object patterns is now disallowed following the spec.
Bug fix:
- Forgot to cherry-pick a diff to fix
flow init
, which was generated an invalid.flowconfig
Likely to cause new Flow errors:
- Strict mode now treats function parameters as
const
- Declaring the exported type of a CommonJS module via
declare var exports: T
is deprecated in favor ofdeclare module.exports: T
Notable bug fixes:
- If a single file (or cycle of files) takes more than 100s to merge (which indicates something is horribly wrong), Flow will emit an error, stop merging that file/cycle, and continue merging the rest of the files.
- Better handling of internal Flow errors during merge. A file (or cycle of files) with an internal error during merge will emit the error and set the type of the exports to
any
. This avoids cascading internal errors.
Misc:
flow get-def
(used by IDEs for jump to definition) now behaves differently for variables introduced by animport
orrequire()
. Previously, it would show where the variable was created, in the import. Now it looks through the import and shows where the variable was exported.- The first steps in a large error message revamp are included in this version of Flow. Larger changes will follow in later versions.
- Some small perf improvements
- A bunch of libdef improvements. Thanks everyone for the PRs!
Parser:
- Enforce that the rest property in object destructuring must be last.
- Fixed a bug which banned methods named
static
in object types
Likely to cause new Flow errors:
- Removed support for static properties on interfaces. Static properties were never well supported, and in most cases their types were not actually checked.
- Fixed the polarity checker, which was not erroring in many places where it should have, like class statics.
- Removed
unsafe.enable_getters_and_setters
option. Getters and setters are now enabled by default. Use theunsafe-getters-setters
lint rule to disable.
New Features:
- Improved error message locations and context around type errors in many cases
- Added
flow cycle
subcommand, which prints a.dot
describing the cycle for a given file.
Notable bug fixes:
- Fixed bug where
[lib]
files outside the Flow root would not be watched for changes - Fixed a few race conditions, which would mask errors depending on the order of imports in a file.
- Fixed refinements on opaque types with declared bounds.
Misc:
- Added
nonstrict-import
lint rule, which requires that strict files can only depend on other strict files. - Added
unsafe-getters-setters
lint rule, which replaces theunsafe.enable_getters_and_setters
flowconfig option.
Parser:
- Added missing
method
property to object type property AST node. - Added support for properties named
static
for declare class and interfaces. - Changed to separate
Variance
AST node for +/- annotations, matching Babylon. - Improved performance by reducing GC pressure.
- Added an
[untyped]
section to.flowconfig
, which treats all matching files as untyped, as if they did not have@flow
. This differs from[ignore]
in that[ignore]
hides matching files from the module resolver /and/ the type system. This allows you to ignore types from third-party modules that are poorly-typed, typed for a different version of Flow, typed with a.flowconfig
with different options, etc. - Experimental: Global find-references for class members.
- Fixed an issue that caused IDE commands (autocomplete, get-def, etc.) to crash in certain cases.
- Fixed an issue that caused IDE commands to return no results when the
this
type is nullable. - Fixed several bugs in lazy mode to avoid crashes and missed errors.
- Issue an error at every location where a particular non-existent module is imported, instead of just the first one in each file.
- For the
get-imports
command, show every location where a module is imported instead of just one per file. - Quite a few libdef improvements.
- Disallow literals as prop keys in assignment destructuring.
Fixed a bug introduced in 0.60.0 in which Flow would not start if its temp directory did not exist.
These changes do not introduce new errors, but error suppressions may need to be moved to the new, more accurate locations.
- Improved positioning of errors involving object types with incompatible indexers.
- Improved positioning of errors involving the arguments of overloaded function types.
-
Introduced a "server monitor" process that acts as an intermediary between client commands and the Flow server.
Previously, the server was only able to service one client request at a time and multiple connections would block until the server is free, preventing the server from telling the waiting clients why it's busy. Now, the monitor can accept many requests and respond more intelligently.
It is also able to detect when the server exits (e.g. when a
package.json
changes) and restart it transparently. -
flow find-refs
can now find local references to class properties. -
New linters:
unclear-type
warns about uses ofany
,Object
andFunction
, since they unsafely circumvent the type system.untyped-import
warns whenimport
ing orrequire
ing a module that does not have@flow
.
-
Made the union created by
$Values
on a frozen object maintain singleton literals. That makes this pattern work:const Enum = Object.freeze({ X: 'x', Y: 'y', }); type EnumT = $Values<typeof Enum> ('a': EnumT); // now errors. previously, EnumT was any string
-
Fixed
Object.keys
and$Keys
on a dictionary of string literal keys, such that the result is now an array of the string literals instead of a generic string:function f(dict: {['hi']: mixed}) { (Object.keys(dict): Array<'hi'>); (Object.keys(dict): Array<'bye'>); // error }
-
Simplified the types mentioned in some error messages, like from "type application of polymorphic type: class type: Foo" to just "Foo"
-
Fixed
get-def
locations on class and object properties -
Fixed
get-def
on refined object properties like the secondprop
inif (foo.prop) foo.prop()
, which previously returned no results -
Fixed non-termination bugs for predicates on classes, unions and polymorphic
instanceof
-
Made recursion limit errors unsuppressable. Please report any such errors, they are always Flow bugs!
- Fixed compilation under ocaml 4.06
- Added dependency on
lwt
from opam - Fixed error behavior of
flow coverage
in--quiet
and--json
modes - Made
--json
consistently imply--quiet
in all commands, notablystatus
- Fixed an issue where a new server may end up writing to the
.log.old
file - Various additions to lib definitions, thanks for your contributions!
- Implemented JSX spread children syntax
- Made missing commas in export specifiers a parse error
- Made
import type *
a parse error
- Adds a
$ReadOnly<T>
utility type which makes all properties on objects read-only.$ReadOnly<{ a: number, b: string }>
behaves as if you wrote{ +a: number, +b: string }
. Read more about property variance on our blog.
type O = { a: number, b: string };
function fn(o: $ReadOnly<O>) {
o.a = 42; // Error!
}
- Allow read-only property initialization in constructors. Covariant properties are still read-only everywhere else in the class.
class X {
+p: number;
constructor(p: number) {
this.p = p;
}
}
- 25% performance improvement on full check time for large projects. (Results may vary.)
- Enables lints in Try Flow. Enable lints with configuration comments like
/* flowlint sketchy-null:error */
.
- Improves positioning for error messages involving exact objects. Notably, this
bug caused error messages against
React.Element
to incorrectly point at library definitions instead of user code.
- Experimental implementation of find-all-references.
- Enforces that exported class statics are annotated.
- Improves typings for Node.js HTTP server
listen()
function. - Removes redundant information from some React error messages.
- Adds parser support for JSX fragments.
- Various correctness changes to which identifiers error on reserved value and type names.
declare class
with multiple extends is now a parse error.
Likely to cause new Flow errors:
- Detect match failures with disjoint unions. Example:
type Foo = { type: 'A', ... } | { type: 'B', ... }` function match(foo: Foo) { switch (foo.type) { case 'C': ... // dead branch, now error! (was allowed previously) ... } }
New Features:
- Support for user-defined "strict" mode. Using
@flow strict
instead of@flow
in the header will now additionally fire lint rules that can be listed in the[strict]
section of.flowconfig
. Here are the current set of supported lint rules (more coming, contributions welcome!).
Error reporting:
- Error location improvements for a bunch of common operations
Parser:
- Tighten the AST around import statements, and rewrite their parsing logic
- Improvements to locations of import statements, export statements, and declare statements
Perf:
- Optimize a hot path in lazy mode, speeding up IDE commands
- Optimize calculation of dependents, speeding up rechecks
- Fix exponential blowup for large enums
Reliability:
- Fix deadlock issues with
flow ide
- Gracefully handle crashes of the file watcher
Misc:
- Don't list ignored files with
flow ls
- Remove flaky support for $Tainted types
- Remove flaky support for
--raw
type printing - Various additions to lib definitions, thanks for your contributions!
Notable bug fixes:
- Fixed a race condition which was causing the Flow server to hang during merge
- Rebuilt the Windows binary
Misc:
- Reverted the change which stopped call properties from flowing to object type dictionaries
Notable bug fixes:
- Fixed a crash when a file goes from parsable to unparsable
- Fixed a server crash when a client dies before receiving a response
Misc:
- Added logging to show which components take a long time to merge
Likely to cause new Flow errors:
- We've manually enumerated all the JSX intrinsics, so Flow might notice if you're misusing an intrinsic.
$Diff
's implementation was rewritten. It should behave mostly the same, but will error on$Diff<ObjA, {x: string}>
ifObjA
doesn't have a propertyx
New Features:
- Flow will now only check the files in
node_modules/
which are direct or transitive dependencies of the non-node_modules
code.
Notable bug fixes:
- A handful of fixes for
flow ide
on Windows - Fixed a few bugs that would cause
flow server
to crash whenflow ide
exits - Fixed a regression in v0.56.0 which caused Flow to crash on
import type *
syntax - Fixed
$ObjMap
's behavior on optional properties - Various fixes for type destructors (like
$PropertyType
,$Diff
, and$ObjMap
) - Object type indexers no longer include call properties. So
{[string]: boolean}
is no longer a subtype of{(number): string}
. - Fixed a bug where circular type imports would miss errors involving union types in rare cases.
Misc:
- Updated Flow headers and license file from BSD3 to MIT
flow server
will now write to a log file in addition to stderrflow ls
will now list the.flowconfig
flow ls
will now list lib files, even if--all
is not setflow ls --imaginary
will list nonexistent files. It's useful for speculating whether or not Flow would care about a file if it existed.- Added
flow force-recheck --focus
which tells a lazy server to start caring about certain files - Various small error message fixes
- Lots of libdef updates! Thanks everyone for the contributions!
New Features:
- Added a
$Rest<A,B>
type, which models the semantics of object rest - Added support for
null
prototypes, a la Object.create(null) - Added support
__proto__
property in object literals and object type annotations
Notable bug fixes:
- Improved support for React higher-order components, e.g. Relay fragment containers
- Improved performance of
flow focus-check
for multiple files - Fixed type-at-post support for $ReadOnlyArray types
- Fixed many cases where error messages were reported far away from the root cause.
- Fixed find-refs for named exports
Misc:
- Added experimental lazy mode for IDEs
- Added
<VERSION>
token forsuppress_comment
option in.flowconfig
- Removed support for $Abstract utility type
- Removed support for
flow typecheck-contents --graphml
Likely to cause new Flow errors:
- Fixed a bug that caused unsoundness with
$ObjMap
.
New Features:
- Flow is now capable of servicing some requests while it is rechecking. This should improve the IDE experience on large codebases.
- Added $Call utility type.
- Added $Compose and $ComposeReverse utility types.
- Added support for spreading
mixed
into an object type.
Notable bug fixes:
- Improve results from the find-refs command.
- Allow null and undefined as React.createElement() config (fixes #4658).
Misc:
- Miscellaneous code cleanup.
- Located error messages related to functions at only the signature, rather than the entire range of the function body.
- Improved error messages when
this
types are incompatible. - Properly check subtype relationships between callable objects.
- Fixed a bug that caused
mixed
not to be properly printed fromtype-at-pos
. - Improved error messages regarding incompatible Array type parameters.
- Preserve some inference information across module boundaries.
- Support assignments to shorthand method properties in object literals.
Typedefs:
- Added captureStream() to HTMLCanvasElement and HTMLMediaElement.
- Added HTMLOptGroupElement return type for document.createElement().
- Added Recoverable and context to the
repl
module. - Fixed return type for AudioContext.createMediaStreamDestination().
Parser:
- Various fixes to improve test262 compliance:
- Correctly disallowed various illegal constructs in destructuring patterns.
- Allow destructuring in
catch
. - Added \u2028 and \u2029 to the list of line terminators.
- Allow unicode escape codes in identifiers.
- Improved parse errors when using private properties outside of classes.
- Disallowed reserved words as function param names in types (e.g.
(switch: number) => void
).
Notable bug fixes:
- Fixed an issue where the server becomes temporarily unresponsive after a recheck and the client consumes all its retries.
Likely to cause new Flow errors:
- Extending a polymorphic class must now explicitly specify the parent class's type args. That is,
class A<T> {}; class B extends A {}
is now an error, butclass C extends A<string> {}
orclass D<T> extends A<T> {}
is ok. - Improved accuracy of type checking calls of built-in methods (e.g. Object, Array, Promise)
Notable Changes:
- Implemented private class fields, part of the Class Fields proposal.
- Implemented "phantom" types (e.g.
type T<Phantom> = any; type X = T<string>; type Y = T<number>
, whereX
andY
are incompatible even thoughT
doesn't usePhantom
) - Unused suppression errors are now warnings instead
- Improved errors involving polymorphic types, so that they now point to the source of the conflict, rather than the nested type args that are incompatible. This was a major source of errors in files other than where the problem was.
- Improved errors involving structural subtyping, so that they now reference the objects that are incompatible in addition to the incompatible properties
- Improved errors when an inexact object type flows into an exact type
- Made rest parameters in object destructuring patterns sealed, and exact if possible
- Improved definitions for some node
fs
functions - Improved performance by removing unnecessary caching
Misc:
- Improved accuracy of type checking of React children in React.createClass
- Fixed a bug related to instantiating a polymorphic type (e.g.
type t = T<U>
) with empty type args (e.g.var x: T<>
) - Fixed polarity checking for property maps
- Fixed a bug where polymorphic types were incorrectly checked for equality
- Improved React definitions
- Added a FLOW_TEMP_DIR env, equivalent to passing --temp-dir
- Added a minimal libdef that defines the few things Flow can't run without, even when using no_flowlibs=true
Parser:
- Added
flow ast --strict
to parse in strict mode without "use strict" - Added support for the RegExp dotAll ('s' flag) proposal
- Added support for the private class fields proposal
- Added support for destructuring defaults in assignments (e.g. given
({ x = 1 } = {})
,x
is 1) - Fixed issues related to
let
,yield
,await
,async
,super
and other reserved words - Fixed issues related to declarations in statement positions
- Fixed issues related to destructuring patterns
- Fixed issues related to IdentifierReferences, like shorthand object notation
- Fixed issues related to class parsing, particularly
new.target
and async methods
Fixed a bug that sometimes crashed the server during recheck
This release includes major changes to Flow's model for React. The following links contain detailed documentation on the new model.
- Defining components
- Event handling
- ref functions
- Typing children
- Higher-order components
- Utility type reference
Please use the new flow-upgrade tool to upgrade your codebase to take advantage of these changes!
Likely to cause new Flow errors:
-
We are modifying how you define React class components. The React.Component class will now take two type arguments, Props and State (as opposed to the three type arguments including DefaultProps that React.Component took before). When your component has no state, you only need to pass in a single type argument. If your component has default props then add a static defaultProps property.
-
Flow used to not type React function refs at all, but now that we are typing refs code that used to just work may now have errors. One such error which can often be overlooked is that the instance React gives you in a function ref may sometimes be null.
-
Flow used to completely ignore the type of React children in many places. Intrinsic elements did not check the type of their children (like
<div>
), the type specified by components for React children would be ignored when you created React elements, and the React.Children API was typed as any. -
In the past when typing children many developers would use an array type (Array) often with the React element type (Array<React.Element>). However, using arrays is problematic because React children are not always an array. To fix this, now use the new React.ChildrenArray type.
New Features:
- Modeling advanced React patterns, like higher-order components, is difficult today because the types you would need are either not provided or undocumented. In this release we added a whole suite of utility types which are all documented on our website.
Notable bug fixes:
- Flow used to have a bug where Flow would consider the following code as valid:
function MyComponent(props: {foo: number}) {
// ...
}
<MyComponent foo={undefined} />; // this is now a Flow error
-
We now allow JSX class components to use exact object types as their props.
-
We now allow member expressions when creating JSX components, e.g.
<TabBarIOS.Item>
. -
We now allow multiple spreads in a JSX element.
-
We have added a type argument to
SyntheticEvents
and correctly typedcurrentTarget
using that type argument.
Parser:
- We fixed miscellaneous character encoding issues.
Misc:
-
This release features a major re-architecture in how Flow typechecks modules against their dependencies. Earlier, Flow would do a "local" (per-module) typechecking pass followed by a global (cross-module) typechecking pass. Now, these passes have been merged. This change vastly improve Flow's memory usage on large codebases.
-
We found and fixed a couple of subtle bugs in the typechecking engine that caused stack overflows in some pathological cases.
-
We made various improvements to refinements. We now recognize
var
s that are only assigned to once asconst
s, so that we can preserve refinements on them through longer stretches of code. Sometypeof
cases have also been fixed. -
We now support focus-checking multiple files. You can use it to debug issues easier and faster by telling Flow to focus on files of interest.
-
This release also includes lots of improvements to core type definitions. Thanks for your contributions!
New Features:
- Flowlint - a linter built into Flow that you can configure to complain about things which aren't quite type errors.
Notable bug fixes:
- Flow now enforces polarity on class supers (e.g. Flow will error on
class B<+T> extends A<T> {}
whenA
's type parameter is not covariant)
- Changed linter (experimental, coming soon) to ignore lint errors in node_modules
New Features:
- Added support for opaque type aliases
- Added library definitions for the Node.js repl module (thanks @zacharygolba!)
Notable bug fixes:
- Fixed library definitions for the Node.js cluster module (thanks @Corei13!)
- Fixed the return type of EventEmitter#setMaxListeners (thanks @ahutchings!)
- Added missing properties in the Node.js fs module (thanks @ahutchings and @rgbkrk!)
- Fixed the length property on $ReadOnlyArray to be covariant (thanks @popham!)
Misc:
- Improved error handling in our test runner
- Fixed type error in our docs (thanks @stenehall!)
- Fixed broken link in docs (thanks @vasyan!)
- Fixed misleading typo in docs (thanks @joelochlann!)
Parser:
- Fixed end locations of various statement nodes to include terminal rparen
- Added separate DeclareTypeAlias and DeclareInterface AST nodes, matching Babel
- Fixed locations of declared vars, classes, and functions in declare export stmts
Likely to cause new Flow errors:
- Fixed a bug that suppressed unrelated errors when a missing annotation error was also suppressed.
New Features:
- Added
$Values
type.
Notable bug fixes:
- Fixed lints appearing in Try Flow.
- Miscellaneous libdef improvements.
- Fixed a couple bugs that could lead to missing push diagnostics when using the persistent connection.
- Made
$ReadOnlyArray
covariant in variance checking.
Fixed an issue where flow init
outputs a [lints]
section (for experimental linting support, coming soon!) that includes all=false
, which is already deprecated. Upcoming versions will support all=off
instead.
Notable bug fixes:
- Optimized performance when typechecking classes
- Optimized performance of sentinel property checks involving large enums
- Lots of libdef updates! Thanks everyone for the contributions!
Misc:
- Fixed infinite recursion from array spread
- Added experimental support for sending errors to an IDE over a persistent connection
- Removed unused --libs flag on status, check, and start commands
Parser:
- Fixed parsing scientific notation with decimal but no fractional part
- Added support for parsing opaque types. Type system support coming soon.
New Features:
- Experimental support for "lazy" typechecking. On large codebases, the Flow
server will start up faster when using the --lazy flag with
flow start
orflow server
, by only computing dependency information and not doing any typechecking. Instead, as files are touched, they are typechecked incrementally along with files that depend on them (and their dependencies). Relatedly, runningflow focus-check
on a file will only check that file and files that depend on it (and their dependencies).
Notable bug fixes:
- Fixed crash in flow.org/try when using JSX (which was a regression in 0.46)
Misc:
- Libdef updates! Thanks everyone for the contributions!
- Removed the libelf dependency from Flow. This helps a few systems, like the standard node docker, that doesn't have libelf available.
- Removed the strip_root .flowconfig option, since it doesn't make sense as a project-specific option and complicated IDE integration. Clients (including IDEs) can still use the --strip-root CLI flag as needed.
- Improvements to handling of Object.prototype
- Improvements to handling promotion of primitives to objects
- Lots of refactoring to improve stability of commands and the typechecker
Likely to cause new Flow errors:
- We are now sealing the object type that is passed to a React component's props. This means Flow will start complaining if you try and access unknown React props.
- Strict function call arity checking is now on for everyone! The
experimental.strict_call_arity
option has been removed. For more, see https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/
Notable bug fixes:
- There are a bunch of flow commands that will quickly try to check a single file, like autocomplete, get-def, check-contents, etc. We're trying to clean up what happens when these commands are given a file with @flow, @noflow, or no pragma. v0.47.0 contains a change intended to avoid doing extra work for files with @noflow or no pragma at all. v0.48.0 should continue to address this.
Misc:
- Libdef updates! Thanks everyone for the contributions!
- In a bunch of situations we're now propagating
any
types and continuing typechecking rather than stopping altogether. - Using a function as an object will now give that object a call property
Parser:
- Optimized parsing of huge list of nested ternary expressions
- The JS version of the parser now throws proper JS errors in the rare case that an OCaml exception is uncaught
Likely to cause new Flow errors:
- We updated the type for the
React.Component
constructor, which means Flow can now infer the prop types based on thesuper(props)
call in a react component constructor. This means components that weren't already declaring their prop types may start getting errors if there are any issues with their prop types. - We fixed the type of
Promise.prototype.catch
, which means code that uses.catch
but wasn't properly handling the exceptional behavior might now have Flow errors
New Features:
- We're updating how get-def (the jump to definition feature) works. It will now jump straight to the definition, even if it's in another file, rather than to the most recent assignment.
- Starting in v0.47.0 we're going to complain when you call a function with more arguments than it expects. You can try it out in v0.46.0 with the
.flowconfig
optionexperimental.strict_call_arity=true
. For more check out this blog post
Notable bug fixes:
- Fixed a exponential blowup that could happen when using functions as callable objects
- Fixed a bug where calling a function with a rest param wouldn't flow
undefined
to unfulfilled parameters. - Fixed a bug where
declare class
classes would be given a default constructor even if they extended another class
Misc:
- Flow is faster! There are a bunch of perf wins in this release!
- Lots of updates to library definitions! Thanks to all our contributors!
- When using the Flow CLI, multiline errors will now show multiple lines of context
- Replaced
--no-suppressions
with--include-suppressed
which is a little bit more well-behaved. - Added
--pretty
flag toflow check
for pretty-printed JSON
Parser:
- Import expressions that appear in a statement list are now correctly parsed as import expressions (thanks @mikaelbr!)
- Fixed the location of
declare function
declarations with predicates - Fixed the location of
yield
expressions with semicolons - Fixed the location of
declare module
declarations - Fixed a bug where array pattern with defaults like
[a=1, b] = c
was parsed like[a=(1, b)] = c
.
New Features:
- Flow now has proper unicode support in its parser!
- Support for
import
expressions (Thanks deecewan!) - Introducing
export type * from ...
, an analogue ofexport * from ...
Notable bug fixes:
- Fixed incremental checking bug when lib files are added or removed
Misc:
- libdef and docs updates. Thanks for the PRs! Keep 'em coming!
Parser:
- Unicode is finally supported! We've moved our lexer from ocamllex to sedlex, which supports unicode!
- Fixed location of unary operator argument when surrounded by parens
- Fixed a bug around using tagged templates expressions as call or member expressions
Notable bug fixes:
- Fixed the definition for
HTMLBRElement
, which extended itself :(
New Features:
- Another big perf win!
Notable bug fixes:
- Internally, Flow wasn't always propagating the any type, which could suppress certain errors. We've fixed this, and Flow now notices some errors it was missing before
Misc:
- Lots of libdef and docs PRs merged! Thanks to everyone for the help!
- Minimum OCaml version is now 4.02
- Partial support for object type spreads with generics
Features:
- Big perf improvement!
Parser:
- Fixed parser to disallow variance sigil for when using object spread.
- Cleaned the flow-parser npm package of cruft. Thanks @zertosh!
Notable bug fixes:
- Some internal refactoring helps Flow find some errors that it was previously missing.
Misc:
- A ton of libdefs updates and documentation fixes. Thanks for all the PRs!
Likely to cause new Flow errors:
New Features:
- Object type spread (
type TypeB = { ...TypeA };
). You can now spread one object type into another! It is designed to mimic the behavior of spreading an object value in an object initializer, where only own properties are copied over. - Experimental new
flow ide
command, through which an IDE can establish a permanent connection with Flow. The IDE can send commands through this connection and Flow can push changes to the IDE.
Notable bug fixes:
- Fixed a bug that would cause Flow's recheck to never terminate
Parser:
- Support for object type spreads.
Misc:
- Lots of updates to the builtin flow libs! Many thanks to all our contributors!
- Object types with dictionaries are now considered sealed (you cannot add new properties to them). This is a minor change, since you can still write to the dictionary.
- We've relaxed the restriction that
React.PropTypes.oneOf
must take an array of literals. You can now put non-literal values in the array.
Notable bug fixes:
- Lots of improvements to typing React components (which may uncover previously missed errors). This release primarily focused on these tweaks to React typing
- Previously Flow did not track much about mixins from
React.createClass
components (including mixed in proptypes). This has been fix and may uncover new proptypes errors in createClass components - The internal React libdef for
findDOMNode
has been updated to includenull
in its return-type now (since this function can, indeed, returnnull
)
Misc:
flow get-importers
has been removed. It was rarely used and added an incredible amount of complexity to the codebase- Lots of updates to builtin flow libs
Notable bug fixes:
- Fixed an edge case when moving .flow files around in a haste project
- Fixed bug which allowed you to add extra properties to exact objects
- Fixed pretty printing of methods in type-at-pos and gen-flow-files
- Fixed the @jsx pragma support's handling of trimming whitespace and filtering empty children. It now matches the behavior of the babel transform
- Fixed some merge_strict_job exceptions
- Fixed bug where Flow would ask for annotations in the object passed to
React.createClass()
even when they were not needed. - Fix so now you can use
this
andsuper
in class method parameter defaults. - Optimization around union types
Parser:
- Fixed a bug where line comments in certain positions were parsed as block comments
Misc:
- Lots of updates to the builtin flow libs! Many thanks to all our contributors!
- Some tweaks to error messages to make them easier to understand.
- We are NOT removing weak mode in this release. See the discussion on #3316
Likely to cause new Flow errors:
- Previous usage of
ReactElement<*>
as a return type for render functions in React may now cause new errors now that a type propagation bug has been fixed. The general solution for this is to remove the return type for functions that return a React element (return types can be inferred by Flow, and Flow has never had a good way to express the type of a specific React element) - Several significant improvements to the locations Flow points to in error messages about objects and property accesses may move errors that were previously suppressed with a suppression comment to a new location
New Features:
- You can now pass
--no-suppressions
toflow check
in order to see what errors would show up in your codebase if you deleted all the error suppressions - New advanced debugging feature: You can now use the special
$Flow$DebugPrint
type to make Flow print a JSON representation of a type. Example usage:declare var flowDebug: $Flow$DebugPrint; flowDebug(someVariable);
- Flow now supports constant-folding of tuple types. In general this means that Flow can now better understand rest elements and array-spreads when tuples are involved.
- Flow now supports spreading types that are iterable (other than just Arrays)
Notable bug fixes:
- Fixed several issues where Flow might not terminate while typechecking complex code patterns
- Fixed an issue where a return type on a class constructor wouldn't properly define the type of objects the class generates if the type was too complex
- Fixed an issue where Flow wasn't properly invalidating refinements after a
yield
expression - Fixed an issue where
Function.prototype.bind()
wasn't working properly on variables typed as "callable objects" in Flow - Fixed some issues where
implements
could cause a"Did not expect BoundT"
error - Fixed an issue where Flow would previously give a cryptic error if the
TERM
environment variable wasn't set (Thanks @SamirTalwar!)
Parser:
- Fixed an issue where the parser previously couldn't handle numbers greater than 2^32-1
- The parser now errors on invalid variance
+
tokens in object types (like it already did for object literals) - Fixed an issue where the parser was incorrectly parsing JS directives (like
"use strict"
)
Misc:
- A few improvements to error messages relating to React PropTypes
- Various core libdef updates
Likely to cause new Flow errors:
- There are some error-position improvements in this release. This means that if you use
// $FlowFixMe
(or any kind ofsuppress_comment
), there's a chance the error may have moved out from under the suppression comment. You may see some unused error suppressions and some previously suppressed errors. - The behavior for tuples has changed to strictly enforce arity. This might cause errors depending on how you use tuples.
New Features:
implements
- classes can now implement one or more interfaces and Flow will verify that the class properly implements the interfaces.- Local find references command:
flow find-refs file line column
- if there is a variablex
atfile:line:column
, then this command returns the location ofx
's definition and the location of all reads and writes tox
. - New shorthand for importing types in the same declaration that imports values:
import {someValue, type someType, typeof someOtherValue} from 'foo'
- Autocomplete now works with exact object types (thanks @vkurchatkin!)
- Tuple types have been revamped. They now strictly enforce arity (docs). This will enable a bunch of future features around spreads and rest parameters. Stay tuned!
$ReadOnlyArray<T>
is the common supertype of arrays and tuples. It's basically an array without stuff likepush()
,pop()
, etc- A lot of tweaks to error messages to make them easier to understand.
- You can declare getters/setters in
declare class
,interface
's, object types, etc. They're still not safely checked, though. - Set
emoji=true
in the.flowconfig
options andflow status
will put emoji in the connection status messages (thanks @zertosh!)
Notable bug fixes:
- You can now use template strings with
require()
, (e.g.require(`foo`)
) Object.keys
no longer returns methods since they are not enumerable- We've relaxed sentinel checks to allow you to check unknown properties. This is consistent with other conditionals
- Flow recognizes type mismatches between the LHS and RHS of a sentinel check as always failing
- Flow recognizes null and undefined checks as sentinel checks too
- Flow used to assume that an array literal with a single element of type
T
had the typeArray<T>
. Now it'sArray<*>
, which lets you add elements of other types to the array. - Fixed
$Shape
to ignore "shadow properties", which are properties that don't really exist, but which have been referenced somewhere. - A few recheck bug fixes. The optimization from 0.37.0 wasn't properly rechecking when property variance changed, when certain locations changed, or when certain files are renamed.
- Fixed mistake where computed getters and setters weren't erroring with
unsafe.enable_getters_and_setters=false
Misc:
- Lots of updates to the builtin flow libs! Many thanks to all our contributors!
make
no longer complains ifjs_of_ocaml
is not installedflow check --profile
now includes CPU timeflow server --profile
andflow start --profile
now print profiling info to the logs- Some optimizations for huge dependency cycles.
tests/
which run a flow server now save the.log
file when they fail- Many tests now run with
--no-flowlib
, which make them much faster
Parser:
- Parsing support for object spread properties
- Fixed
kind
of a static method namedconstructor
to be"method"
rather than"constructor"
- Support for new
import type
shorthand - OCaml AST for getters and setters is a little cleaner now
- We now support defaults in setters
- The bug fix for trailing commas in array lists was accidentally reverted and has been re-committed.
Notable bug fixes:
- 1 more server recheck fix... Fourth time's a charm!
Notable bug fixes:
- 1 more server recheck fix... Third time's a charm!
Notable bug fixes:
- Fix more issues in the server with rechecking changed files
Notable bug fixes:
- Fixed an issue in /try where Flow was using an ocaml regex API that couldn't compile to JS
- Fixed an issue where a changed "literal" type in a module signature wouldn't cause the Flow server to recheck
- Fixed an issue where an update of a module in a cycle may not properly recheck all of its dependencies in the Flow server
Likely to cause new Flow errors:
- There are some error-position improvements in this release, which means that if you use
// $FlowFixMe
(or any kind ofsuppress_comment
), there's a chance the error may have moved out from under the suppression comment to a different location that's more indicative of the error position.
New Features:
- LOTS of built-in libdef updates.
- It's now possible to use
import type
/import typeof
inside the body of adeclare module
to import types between libdefs.
Notable bug fixes:
- Fixed an issue where dictionary types couldn't flow into a covariant-compatible version of themselves.
- Fixed an issue where previously
any + number
would yieldnumber
. Now it correctly yieldsany
. - Don't try to read from the filesystem at all when using
flow check-contents
where input is provided via stdin.
Misc:
- The
--old-output-format
CLI flag is now gone. - Performance optimization that allows us to skip re-checking any recursive dependencies of a changed file when the file's types haven't changed
- Improved error positions on property assignment type errors.
- The
parse()
function in theflow-parser
NPM module now takes either 1 or 2 arguments. Previously it would require both arguments in order to work. - Things typed as "callable objects" now inherit from Function.prototype rather than Object.prototype.
Likely to cause new Flow errors:
- We've been working on improving error messages, which often involves moving the errors closer to where the error is likely triggered. If you use error suppressing comments, some of your comments now appear unused, since the error moved.
New Features:
- Lots of small improvements to error messages
flow ls --all
will output libs and ignored files tooflow ls --explain
will explain why Flow cares or doesn't care about a fileflow ls dirA/ dirB file.js
will only list files underdirA/
, files underdirB/
, andfile.js
Notable bug fixes:
- Calling a method through computed properties (
obj['method']()
) is now supported - The client no longer consumes retries and waits patiently when the server is busy garbage collecting
- Errors in lib files with
--strip-root
set now show context again
Misc:
- Currently
flow coverage
andflow check-contents
default to treating all input as if it has the@flow
pragma. We will change this in a future version. To make this transition easier, both commands now have the flags--all
and--respect-pragma
, where--all
is the current behavior and--respect-pragma
is the future behavior. - Better error messages for unsupported destructuring.
- Builtin libdef improvements
- Fixed a TDZ issue which would allow
let x = x;
Parser:
- Fixed a bug where
[...rest, 123]
was incorrectly parsed
Likely to cause new Flow errors:
- Flow now knows that calling
addEventListener()
with'click' and 'dblclick'
will pass aMouseEvent
to the listener. This means you might need to updatefoo.addEventListener('click', (e) => bar())
tofoo.addEventListener('click', (e: MouseEvent) => bar())
.
New Features:
- Better error messages in a bunch of situations
- flowtype.org/try now has an AST tab that shows the parsed AST of the example
Notable bug fixes:
- Bindings that come from imports are now treated as const
- Found and fixed a few situations where Flow was emitting redundant errors
- Some if statement refinements were sticking around after the if statement in some situations when they should not have.
Misc:
- Various libdef fixes and improvements
- Various docs fixes and improvements
- If
foo
has the typedmixed
, we now allowfoo.bar
if you check thatfoo
is notnull
orundefined
.
Parser:
- Better error message if you try to make a class property optional (currently unsupported)
- Dropped support for
let
statements, which never made it into the spec (thanks @andreypopp)
Likely to cause new Flow errors:
- Dictionary types (i.e.
{[key: string]: ValueType}
) were previously covariant which proved to be a significant source of unsoundness. Dictionary types are now invariant by default in order to fall into consistency with other collection types. It is possible to opt in to explicit covariance with new syntax:{+[key: string]: ValueType}
, but note that this is now enforced covariance -- which means the dictionary can no longer be written into (only read from). For mutable collections, consider usingMap
/Set
/etc. Please see this blog post for more information on variance. - Object property types are now invariant by default. New syntax allows explicit opt-in to enforced covariance:
type T = {+covariantProp: string}
. Please see this blog post for more information on variance. - Object method types are now covariant by default. So this:
type T = {covariantMethod(): string}
is the same astype T = {+covariantMethod: () => string}
. Please see this blog post for more information on variance.
New features:
- New
empty
type annotation. This is the "bottom type" which is the type that has no possible values. This is mostly useful for asserting impossible types right now (see the commit description for more details). - All server commands now have a
--quiet
flag to suppress server-status information that would otherwise be printed to stderr. - It's now possible to specify an "@jsx" pragma to override the implicit default of
React.createElement
. See the commit message for more details. - async iteration is now Stage 3, so Flow now supports async generators and
for-await-of
statements.
Notable bug fixes:
- Calling
get-def
andautocomplete
on specifiers in import statements now works properly and links in to where the specifier is exported in the other file. Generator.prototype.return
now returns a possibly-unfinishedIteratorResult
object rather than a definitely-done iterator result. See #2589 for more details.- Fixed an issue with inferring the proper return-type of iterators coming from a generator with multiple return-types. See #2475 for more details.
- Fixed an issue where a non-polymorphic class-instance used as a CommonJS export wasn't omitting underscore-prefixed members when the
munge_underscores
config option is set totrue
. - Fixed an issue where Flow would previously not consider non-@flow files when re-calculating type dependencies on a change to the filesystem. This caused sporadic issues where Flow might think that a module is missing that actually is not! This is now fixed.
Misc:
- Significant memory usage optimizations by normalizing common aspects of the many "reason" structures stored in memory to use ocaml variants.
- Significant memory usage optimization by compressing the contents of the shared heap used by the persistent server.
- Parser now allows for duplicate properties and accessors in objects per the latest ES spec.
- Flow parser is now tested against esprima3 tests
yield
expressions no longer evaluate to an optional type. This is unsound, but the inconvenience was so prevalent that we decided to relax the issue for now. See #2080 for more details.- Various core libdef updates.
Parser breaking changes:
- Updated the parser to use the latest
ExportNamedDeclaration
andExportDefaultDeclaration
nodes from ESTree rather than the outdatedExportDeclaration
node. export default class {}
now correctly emits aClassDeclaration
rather thanClassExpression
per this estree issue.- Updated
ExportSpecifier
property names fromid
->local
andname
->exported
per the latest ESTree spec. - Update
ExportBatchSpecifier
to aExportNamespaceSpecifier
node per the latest ESTree spec. - Renamed
SpreadElementPattern
->RestElement
per the latest ESTree spec. - Node-properties of
ObjectPattern
are now namedProperty
andRestProperty
per the latest ESTree spec. - Use a
Super
node now instead of anIdentifier
node per the latest ESTree spec. {ImportNamedSpecifier
andImportDefaultSpecifier
nodes now use properlocal
andremote
property names, per the latest ESTree spec.- The
mixed
type annotation is now represented with a specialMixedTypeAnnotation
node (same as Babylon has been for a while). - The
NullTypeAnnotation
annotation node is now calledNullLiteralTypeAnnotation
in order to match Babylon.
Likely to cause new Flow errors:
- Its now an error to add
mixed
tonumber
New features:
suppress_comment
now defaults to matching// $FlowFixMe
if there are no suppress_comments listed in a .flowconfig- The Flow server no longer restarts itself when a
package.json
file is changed - The Flow server no longer restarts itself if a libdef file is touched, but not actually changed
- Added support for using Iterables with
Promise.all()
(thanks @vkurchatkin!)
Notable bug fixes:
- Fixed an issue where some predicates could cause Flow to crash
- Fixed an issue where we weren't properly looking things up on
Function.prototype
andObject.prototype
- Fixed an issue where Flow could crash when extracting coverage on empty types
- Fixed an issue where long paths that are ignored could give a bunch of warnings on Windows
- Fixed an issue where
flow get-def
wouldn't hop to the location of a type coming through animport type
- Fixed an issue with dictionary types where using an
any
-typed variable as a computed-property lookup results in the wrong property-value type - Fixed some issues where Flow wouldn't allow definition of properties or methods called "static" on classes
- Fixed an issue where Flow wouldn't permit
throw
s at the toplevel of a module - Fixed an issue where adding a file to
[libs]
with an extension not listed inmodule.file_exts
, it would previously be silently ignored - Fixed an issue where
import * as
on adeclare module.exports: any;
libdef would not result in a module with every possible named export - Fixed a parsing issue where
"JSX attributes must only be assigned a non-empty expression"
syntax errors sometimes point to the wrong line - Fixed parsing of setter methods with destructured parameters
- Fixed a parsing issue where it wasn't possible to use
get
orset
in object short notation - Fixed a parsing issue where we previously weren't allowing strings in async method names:
x = { async 123() { await y; } }
- Fixed an issue where the parser previously wouldn't recognize the
u
regex flag
Misc:
- Various built-in libdef improvements
- Various significant shared memory optimizations
- When a package.json key is read by Flow during module resolution, don't wrap it in quotes
- Added parser (but not yet typechecker) support for
new.target
- Added
--pretty
flag to all commands that have a--json
flag - Flow now prints an exception instead of segfaulting if there is a heap overflow
- Only print JSON for
flow coverage
when--json
is passed (thanks @aackerman!)
Parser breaking changes:
- Removed 'lexical' property from
SwitchStatement
- Removed
guardedHandlers
fromTryStatement
- Use
AssignmentPattern
for function param defaults to match ESTree - Use
RestElement
for function rest params to match ESTree - Fixed the location info for
ExpressionStatement
- Fixed the location info for
CallExpression
andMemberExpression
Notable bug fixes:
- If Flow runs out of heap space, it now throws an exception instead of segfaulting.
Likely to cause new Flow errors:
- If you check that an object
obj
has a propertyfoo
that Flow doesn't know about, Flow will now refineobj.foo
to the typemixed
. If you then try to useobj.foo
in an unsafe way (like as a function), you might start seeing errors mentioningproperty `foo` of unknown type
. The fix is to either fix the type ofobj
to include an optional propertyfoo
, or to rewrite code likeobj.foo && obj.foo(x)
totypeof obj.foo === "function" && obj.foo(x)
- We've fixed the type of
Array.prototype.find
to reflect the fact that it can returnundefined
- We've tightened up the checking of tuple types
New Features:
- New syntax for exact object types: use
{|
and|}
instead of{
and}
. Where{x: string}
contains at least the propertyx
,{| x: string |}
contains ONLY the propertyx
. - Flow now watches for
.css
,.jpg
,.png
,.gif
,.eot
,.svg
,.ttf
,.woff
,.woff2
,.mp4
and.webm
files (this list is not configurable at the moment). We call them resource files. If you require a resource file, you get astring
(except for.css
files, for which you get anObject
). You should still be able to usemodule.name_mapper
to map a resource file to a mock, if you prefer. - We're starting work on
flow gen-flow-files
, which consumes Flow code and outputs.flow
files containing only the types exported. It's alpha-level and we're still iterating on it, so use at your own peril!
Notable bug fixes:
- Fixed a bug where, if a module has a CommonJS export of type
any
, then the types it exported were also given typeany
- v0.31.0 contained a regression where arrays and promises required more annotations than they should. This is fixed.
- Fixed use of tagged unions with intersections and generics.
- Jump to definition for overridden methods was jumping to the wrong method. This is now fixed.
flow coverage
had a non-termination bug. This is now fixed.
Misc:
- Lots of improvements to the builtin libdefs! Thanks for all the pull requests!
Likely to cause new Flow errors:
- Fixed an issue where an
any
type could actually prevent errors from showing up in places that actually should surface errors Array.isArray()
now refines arrays toArray<mixed>
instead ofArray<any>
New Features:
- When the
munge_underscores
option is set, Flow no longer requires annotations on exported classes with munged methods. (thanks @pvolok!) - Added a new "magic" type called
$PropertyType<T, 'x'>
. This utility extracts the type of the property 'x' off of the type T. - It is now possible to use leading-
|
and&
on any type annotation, not just in type aliases
Notable bug fixes:
- Significant perf improvements on checking disjoint unions
- Fixed an issue where
flow start
would sometimes hang on Windows - Fixed an issue where
flow get-def
on a react element would always point to the internal react libdef (rather than the component that defines the element) - Error messages for builtin types are now more descriptive in more scenarios
- Fixed the order in which destructured function params were processed. This previously caused issues with variable references within the destructuring
- Error messages for union type errors now point to more helpful locations in some cases
- Fixed a long-standing confusing error message blaming property accesses on the "global object" (when the global object isn't actually involved at all)
- Improved error message when trying to import a named export from a module that only has a default export
- Fixed an issue where
Promise.resolve(undefined)
would not always error as it should - Fixed an issue where async functions that return void do not properly enforce their return type
- Fixed an issue where aliased object types may not error when an invalid property is accessed on them
- Fix
flow coverage
when reporting coverage on empty files - Printed types in some circumstances (autocomplete, type-at-pos, etc) are now capped on size to prevent overflows in tools that consume them. When the size overflows the cap,
...
will be printed as an overflow placeholder - Various built-in libdef updates
Likely to cause new Flow errors:
- Fixed
React.PureComponent
's definition, so previously missed errors are now reported - The definition of
console
in the build-in libdef has been filled out and is no longerany
.
New Features:
- From now on we're going to start publishing Windows builds with each release. Please report any issues you have!
- Forward references in type annotations: you can now reference a class in a type annotation before the class is declared
- T is now covariant in
Class<T>
. So if classB
extends classA
, thenClass<B>
is now a subtype ofClass<A>
- Flow now lets you destructure objects with computed keys.
flow check-contents --respect-pragma
-check-contents
checks whatever you give it, regardless of@flow
or@noflow
. This option changes the behavior to respect the pragma.flow check-contents
will now report parsing errors too (thanks @nmote!)
Notable bug fixes:
- Fixed
--trace
behavior when we unify types - Fixed situation where the client could spin-wait for the server
- Fixed non-termination triggered by certain calls to
Function.prototype.{apply,call}
- Fixed issue where "Duplicate module provider" errors would stick around even after being fixed.
- (Windows) Fixed how the flow client tails the flow server's logs
- (Windows) Fixed the log rotating
- (Windows) Fixed issues where Flow would report Process Handles instead of Process IDs, leading to bad messages and a non-functional
flow stop
- (Windows) Fixed build outside of a git or hg repository
- (Windows) Better error messages when you have paths that are too long
Misc:
undefined
is now just a global variable declared in the libdefs- Various built-in libdef improvements
- Nifty PR from @nmn which teaches flow that
nullableArr.filter(Boolean)
is non-nullable
New features:
- Tagged unions of interfaces should now work in the same way that tagged unions of type aliases work.
Notable bug fixes:
- Building Flow outside of a git or hg repo should work now
- If you declare an overloaded function with one overload that handles a
string
argument and one overload that handles anumber
overload, then passing in a unionstring | number
should now work. - Annotations for destructured patterns now work like non-destructured patterns. Types no longer flow through these annotations, rather they are checked against the annotations and then the annotations are used instead.
- Allow
import {type} from "Foo"
- We had a bug where Flow wouldn't complain about duplicate haste modules. This is now fixed
- Fix for edge case hit when using
experimental.strict_type_args=false
and type parameter upper bounds.
Misc:
- Various built-in libdef improvements
- Some error location fixes
- Lots of Windows support work. Should build and mostly work, but not fully stable yet.
- Some performance wins
flow check --json --profile
now includes profiling info in the JSON response
Likely to cause new Flow errors:
- Significant fix to matching members of union types. This fix very likely surfaces typechecking issues that were missed before. Check out the blog post for more details
- Variables in template literals are now subject to the same rules as variables being concatenated with a string using
+
. This may surface template strings with variables that may not safely coerce to a string. - Type arguments are now required to be specified for type annotations that have type arguments. Previously they were implicitly filled in as
any
-- but now this must be explicit. This behavior is toggleable viaexperimental.strict_type_args=false
, but this config option will be removed in a near-term future release. There is also a codemod to help you automatically update old code.
New Features:
- Support for
declare export
withindeclare module
bodies. Whendeclare export
is used, the module being declared is inferred as an ES module. This enables the ability to export both named and default exports usingdeclare module
.
Notable bug fixes:
- Fixed a bug on OSX where Flow might crash in rare circumstances
- Fixed an issue where automatic semicolon insertion for class properties wasn't behaving properly in some circumstances.
- It is no longer required to annotate a property on an exported class if an initializer value is present. Instead, the initializer value itself can be directly annotated. This makes annotation of class properties that are functions much less cumbersome.
- Fixed a race-condition where Flow may not properly error when it encounters two modules with the same name (using the "haste" module system)
Misc:
- Flow now looks for
@flow
in all comments at the top of the file (rather than just the first). It's also possible to configure this using a newmax_header_tokens
.flowconfig option. - Various built-in libdef improvements
- Performance improvements for the
flow coverage
command
Notable bug fixes:
- Fixed a filesystem race condition where Flow would note that a directory exists just before it is deleted, then try to read the directory
- Fixed some issues with disjoint unions that have complex definitions
- Fixed an issue where functions that come after a return aren't analyzed (even though they are hoisted)
- A few updates to the Node.js library definitions
- Fixed a race condition when adding specific properties to dictionary types
- Various performance improvements
--strip-root
is now applied to the output of--verbose
- Fixed an issue where duplicate method declarations weren't understood correctly
(@gabelevi mistakenly listed a few v0.26.0 changes as being in v0.25.0. The Changelog has been updated to reflect reality. Sorry!)
Likely to cause new Flow errors:
- Flow now understands stateless functional React components, which may reveal many errors if you use them heavily.
New Features:
- Support for stateless functional React components!
- Support for the exponentiation operator (
**
) - New
flow ls
command to list the files that Flow can see.
Notable bug fixes:
- Fixed parsing of
/x/* 5 */y/
- that's no comment! - Fixed parsing of newlines or comments at the end of a template literal.
- Fixed an incremental bug where Flow didn't notice new JSON files in certain situations
- Fixed a parsing service crash when a file appears and disappears suddenly.
Misc:
- Restored a bunch of deprecated/experimental/browser-specific APIs to the builtin flowlib and made them optional
- Fixed up parser tests and further integrated them into CI.
- Lots of refactoring!
Likely to cause new Flow errors:
-
@marudor made a tremendous effort to clean up the builtin flowlib definitions, adding missing things, fixing annotations, and removing non-standard and deprecated features. If you're relying on these things, then you may have new errors.
-
In the past, generic types could leave off the type arguments. Flow is moving towards making these required. Applying type arguments to a polymorphic type (e.g.
Map<string, number>
) is like calling a function. If writingmy_function
was the same thing as writingmy_function()
, it would be really difficult to pass functions as values. Similarly, by making type arguments required, it frees us up to do more with our polymorphic types. If you have a polymorphic type with default types, liketype Foo<T = number>
, you can now writeFoo<>
to apply 0 type arguments to the polymorphic typeFoo
.To ease migration, v0.25.0 still allows you to omit type arguments by default. v0.27.0 will start enforcing that type arguments are always supplied. To enable this behavior in v0.25.0, you can add
experimental.strict_type_args=true
to the.flowconfig
.
New Features:
declare module.exports: type;
<-- this is the new syntax to declare the CommonJS export type. Previously, you had to writedeclare var exports: type;
. This can be used in.flow
files and indeclare module
declarations.
Misc:
- Now Flow builds on OCaml 4.03.0
- Fixed up the parser tests (thanks for the help @marudor!) and have started running those in CI
- A ton of refactoring and clean up
- Fixed a bug where Flow might run out of memory in a repository with a lot of non-flow files
- Fixed a bug where
autocomplete
can show internal variable names for files that use destructuring
New features:
- Many common errors now have more contextual error messages. Check out the test file changes to see what this looks like!
- If a
<PROJECT_ROOT>/flow-typed/
directory exists, Flow will now assume it is a [libs] directory by default to help reduce the amount of out-of-the-box configuration that is necessary. (Thanks @splodingsocks!) - Support for specifying a default on a type parameter declaration. For example:
type Iterator<Yield, Return=void, Next=void> = ...
.- NOTE: The pull request to add syntax support for this is pending, so it may be necessary to wait on that to ship before using this feature
Notable bug fixes:
- Fixed the
flow coverage
command. - Fixed crashes when running
type-at-pos
anddump-types
over destructuring. - Fixed a refinement bug when evaluating a method call on a refined variable in some cases.
- Fixed an issue where some system commands could throw if Flow attempts to read a directory that it doesn't have permission to read.
- Fixed a bug where the inferred return type of some functions that might return
void
could end up as exactlyvoid
(rather than a union of the possible return types). - Fixed a bug where the server would crash if a
.json
file is deleted after a server was already running. - Type applications that don't have the right number of type parameters (i.e.
Map<number>
) now emit a more clear error. - Lots of dom/bom improvements sent in from contributors! (big thanks to @marudor for lots of these!)
Misc:
- Better locations for logical operator errors
- Better error message sorting:
- Sorts errors in
.json
files by name coalesced with.js
files - Sorts all internal errors before parse errors before type/inference errors
- Sorts lib file errors before source file errors
- Sorts errors in
- Perf improvements for some comparisons of polymorphic types
- Fixed parsing of JSON files with duplicate object keys
Likely to cause new Flow errors:
- When you refine a
mixed
variable withtypeof myVar === 'object'
, we used to refine the type ofmyVar
tonull | Object
. Now it is refined tonull | {[key: string]: mixed}
. This meansmyVar.prop
has the typemixed
rather thanany
. - Removed non-standard Promise methods. Previous versions of Flow specified the type of Promise.prototype.done and Promise.cast, which are not standard or implemented in browsers. If you rely on a polyfill that does provide these methods, you can redeclare the Promise class in your project's local libs folder. Note that you need to copy the entire class declaration from lib/core.js in order to add methods and properties. It's not currently possible to extend the builtin declarations, but it is possible to redefine them.
New features:
- Errors involving union or intersection types now include more information about why the various branches failed
flow init
now has more command line flags to specify what should be in the created.flowconfig
flow ast
now can parse JSON files- Comments are now supported in
.flowconfig
files. Lines starting with#
or;
are ignored - In the
[ignore]
section of a.flowconfig
you can now ignore a relative path with<PROJECT_ROOT>/path/to/ignored
- Most
flow
commands have an--ignore-version
flag to skip the version check specified in the.flowconfig
. - Added a
module.use_strict
option to the.flowconfig
. When it is true, Flow will treat every file as if it has the"use strict";
directive. - Using strict equality, you can now refine the
number
type into number literal types. (e.g. afterx === 0
Flow now knows that x has the type0
) - Flow no longer requires return type annotations for exported functions if Flow can fully infer the type.
flow force-recheck FILE1 FILE2
command tells the flow server thatFILE1
andFILE2
have changed and that it should recheck. This is intended for tooling that might be racing the file system notifications.- Flow is smarter about what
!x
evaluates to for various types ofx
. <Foo />
is now allowed whenFoo
is astring
. If$JSXIntrinsics
is defined,Foo
must be a subtype of$Keys<$JSXIntrinsics>
- Support for class decorators in addition to property decorators (also gated behind the
esproposal.decorators
config option). Thanks @marudor!
Notable bug fixes:
- Disallow
(obj: SomeClass)
except for whenobj instanceof SomeClass
- Fixed setting temp dir via the
.flowconfig
- Added missing
all
flag to the.flowconfig
- Fixed a bug when destructuring a non-literal object type using a pattern with defaults
- Fixed the
--strip-root
flag for displaying errors - Classes can now have properties named
async
- Fixed refinements like
if (foo[0]) { ... }
, which should work likeif (foo["prop"]) { ... }
does. That is, Flow should remember thatfoo[0]
exists and is truthy. - Fixed parsing docblocks with CRLF line endings
- Fixed autocomplete within if statements
Misc:
- Added more info and structure to JSON output, without removing or existing fields
- Loads of improvements to the builtin libraries
- Bunch of perf improvements
- Clarified some errors messages and error locations
flow start --json
will start a server and output a JSON blob with info about the new server- Slowly improving tracking side effects in switch statements
- Some improvements to pretty printing errors
Object.values()
andObject.entries
returnArray<mixed>
andArray<[string, mixed]>
respectively, since Flow currently is never sure that it knows about every property in an object.
- Patch release to fix some JSON parsing issues that went out in v0.22.0
Likely to cause new Flow errors:
- Overhaul of Flow's understanding of React APIs. Some of these updates remove old/deprecated React APIs. Check out the new React docs for an overview of how things work.
New features:
- Flow now gives precedence to library definitions over non-@flow implementation files. This means that it should no longer be necessary to specify a
node_modules
dependency in the[ignore]
section of your.flowconfig
if you have a library definition defined for that dependency. - Significant improvements to
Promise.all
: We now preserve the type of each item in the array passed toPromise.all()
so that it may be propagated through to the resulting.then()
handler. - We no longer try to parse files that are not marked with an
@flow
pragma. We anticipate this will improve performance for projects with large, non-Flow node_modules directories. - Classes with static members are now subtype-compatible with structural object types
- It is now possible to specify a leading
|
or&
for type aliases of long unions/intersections. This is useful, as one example, for disjoint unions with a large number of members (where each member sits on a new line):
type MyDisjointUnion =
| {type: 'TypeOne', ...}
| {type: 'TypeTwo', ...}
| {type: 'TypeThree', ...}
...
;
Bug fixes:
- Fixed an issue where an intersection of two object types did not always properly combine to match objects with members on both sides (facebook#1327)
- Fixed an issue where an object of some intersection type could not be used with the spread operator (facebook#1329)
- Fixed an issue where refinement-testing on an object of an intersection type wouldn't always work (facebook#1366)
- Fixed an issue where an intersection of function types with a common return type should type check against function types with union of param types
- Fixed an issue where refining
obj['abc']
didn't behave quite the same as refiningobj.abc
- Fixed an issue where usage of
flow get-def
on the left-hand side of arequire()
wouldn't hop through therequire()
and to the actual location of the definition - Fixed an issue where Flow would not give a clear error when trying to use
import type
to get a non-type export - Fixed an issue
flow dump-types --json
was not as robust as it could be against outputting valid JSON in the event of certain kinds of errors - Fixed an issue where Flow would not give a parse error if multiple ES exports with the same name are exported from a single ES module
declare class
declarations now properly define a built-inname
property (like real class declarations do)
Likely to cause new Flow errors:
- ES6 react classes without state should now
extends React.Component<DefaultProps, Props, void>
(previously it wasextends React.Component<DefaultProps, Props, {}>)
- ES6 react classes with state should declare
state: State;
- Before, it was possible to test for properties in objects which did not exist (
if (o.noSuchP === foo) { ... }
). These kinds of checks will now cause a type error.
New features:
- Autocomplete for jsx properties
- Typed JSX intrinsics. This means you can list which jsx intrinsics exist (like
div
,span
, etc) and specify which properties they have. - Syntax for declaring variance at definition. For example,
interface Generator<+Yield,+Return,-Next> {...}
. Still pending transpiler support though. - Refining
string
and union types with string equality now properly refines the types. - Support for
export * as
from @leebyron's Stage1 proposal. Babel support here
Notable bug fixes:
- Fixed bug with class expressions due to
this
type - Fixed autocomplete for
this
- Recognizes exhaustiveness in
switch
statements withdefault
case. - Fixed "Did not expect BoundT" errors
- Fixed infinite loop in certain recursive types
- Fixed an incremental mode issue with deleted files
- Fixed an incorrect refinement when assigning an object to a variable.
Misc:
- Some internal errors now will be made user visible instead of silently failing. They generally mean that Flow has some bug or is making an untrue assumption/assertion. If you see these please report them!
- Improvements to how we report certain types (type application, optional types) via our APIs
- Various sentinel improvements, including boolean sentinels
- Various improvements to the builtin flow libraries (thanks everyone for the pull requests!)
Bug fixes:
- Ironed out some issues with the
this
type
Misc:
- find package.json using normal parsing phase
New features:
- Initial support for a
this
return type for class methods - Big improvements on error messages for unions and intersections
import typeof * as
now allows for concise access to the type of the ModuleNamespace object- Flow now understands how to
require()
/import
a .json file
Bug fixes:
- Fixed an issue where nested unions and intersections might not typecheck as expected
- Fixed issue where
declare type
wouldn't work in adeclare module
that has anexports
entry - Fixed an issue where the error formatter could fatal in some rare cases
- Fixed a bug where
Function.prototype.bind
would lose the types of the params on the function it output - Fixed some variance bugs in the built-in Array.prototype library definitions
- Fixed a bug where using a list that doesn't contain ".js" in
module.file_ext
would cause internal flow libs to be ignored - Fixed autocomplete to work better with general
Function
types - Fixed some issues with const refinement
- Fixed various issues with
export * from
(it should work fully now) - Fixed a bug where Flow might crash when an export has a wildcard typeparam
Misc:
- Some improvements to DOM and Node libdefs
- Various error position relevancy improvements
- Significantly improved general understanding of special functions like
Function.prototype.{bind,call,apply}
- Improved error messages for
import
statements where the remote exports don't exist (or may be typo'd) - Improvements to understanding of deferred initialization of
let
variables flow get-def
will now hop through lvalues in variable assignments for more fine-grained "hop-tracing" of a variable back to its definition- Objects with a
callable
signature can now be passed in to type positions that expect a function with a matching signature - Significant improvements to efficiency/perf when recalculating types based on a change to a file with an already-running Flow server
Likely to cause new Flow errors:
- Flow syntax is now disallowed in non-
@flow
files. Use@noflow
to work around this import type * as Foo
is now disallowed in favor ofimport type Foo
require()
can only take a string literal- ES6 react classes without defaultProps should now
extends React.Component<void, Props, State>
(previously it wasextends React.Component<{}, Props, State>)
- ES6 react classes with defaultProps should declare
static defaultProps: DefaultProps;
- Flow notices errors it missed before in
React.createClass()
react components - Flow is now stricter about using uninitialized variables
- Stricter checking of
in
keyword
New Features:
flow coverage
commandnull
type annotation- Support for class field initializers, gated by
.flowconfig
options - You can now override flowlib definitions with local lib files
- Basic support for computed properties
- Declaration files (.flow files). Long story short, if
foo.js
andfoo.js.flow
exist, Flow will prefer the latter and ignore the former. declare export
- a way to declare the exported types in a non-lib file- Array rest destructuring assignment support
Notable Bug Fixes:
- Fix "package not found" error in some symlink situations
- Object indexer should not imply callable signature
- Default param values can reference earlier params
- Fixed a case where we weren't substituting type parameters properly
- Fixed a situation where Flow would prefer an unchecked module over a library definition
Misc:
- Add
--root
arg to most client commands - More repositioning of error locations
flow get-def
: Jump to module named in import statement- Lots of fixes to make flow commands smarter about connecting to the server
- Smarter refinement in a bunch of situations
- freeze imports on all modules, and require() on ES6 modules
- You can now spread classes, like
var {x} = new Foo()
- Interfaces now can be callable
- If you've refined an object property, that refinement survives access through a destructured refinement
- Better autocomplete results for primitives, objects, functions and unions
flow server
will write to log file in addition to stdout/stderr
Likely to cause new Flow errors:
- Flow is now stricter (and more consistent) about how
null
works when used as an initialization value for object properties that are mutated later. Solet o = {prop: null}; o.prop = 42;
is now an error and requires thatnull
be annotated:let o = {prop: (null: ?number)};
. - The return type of RegExp.prototype.match() is now properly annotated to return a nullable.
New Features:
- We now take advantage of the guarantee that
const
variables are read-only when doing refinements. This means that refinements ofconst
variables now have much fewer caveats than refinements oflet
s orvar
s. For instance, it's safe to depend on the refined type of aconst
within a local function created in scope of the refinement, even if the function escapes. - We now track which external variables a function actually modifies, and forget refinements to only those variables when a function gets called.
- New config options:
esproposal.class_static_fields=warn|ignore
andesproposal.class_instance_fields=warn|ignore
. This allows the new ES class fields syntax to be ignored. - New config option:
module.system.node.resolve_dirname
. This allows configuration of the name of thenode_modules
directory (or directories) used by the node module system. This is similar in behavior to webpack's resolve.moduleDirectories config option. - Added support for a
<PROJECT_ROOT>
token in the template string for themodule.name_mapper
config option. This token will be replaced with the absolute path to the current project root before mapping the module name. For example:module.name_mapper='^\(.*\)$' -> '<PROJECT_ROOT>/src/\1'
would canonicalize an import from"foo/bar/baz"
to"/path/to/root/of/project/src/foo/bar/baz"
.
Notable Bug Fixes:
- Fixed a bug where we were enforcing TDZ on reads to let/const, but not on writes.
- Fixed a bug where any refinement clearing that occurred as a result of a function called in an if-statement was forgotten, meaning that lots of refinements were incorrectly allowed to stand.
- Fixed a bug where generator code couldn't previously call
yield
without an argument. - Several improvements to generators.
- Various improvements and bug fixes for TDZ enforcement.
- Various other small improvements to refinements.
- Fixed an issue where errors could sometimes spew to stdout rather than stderr.
Misc:
- Removed
flow single
as it is effectively redundant withflow check --max-workers=1
. - The "server starting" output now gives more insight into progress.
flow --version
is now deprecated in favor offlow version
.
New Features:
- New default error message format shows the code inline (thanks @frantic!)
- Autocomplete will keep trying even if the file fails to parse
- You can configure which file extensions Flow looks for (thanks @eyyub!)
- Support for negative number literal types.
Notable Bug Fixes:
- Incremental
make
on OSX now works whenlib/
files change - Fixed some issues around const destructuring
- Fixed some issues around destructuring in for-of and for-in loops
- Some emacs plugin fixes
- Object spreads are now handled in the correct order
- Generator
return()
andthrow()
methods are now supported - Object types now allow keywords as the object keys (thanks @samwgoldman!)
- importing & exporting
default
using named specifiers is now supported Flow
now understandsthis
in class static methods andthis.constructor
in class instance methods (thanks @popham!)- Fixed bug with array spreads
- Understand that all classes have a static
name
property
Misc:
- Improved
flow find-module
- More error location improvements
Object
can now be called as a function to cast things to objects- We've tried to standardize the error codes with which Flow exits. Some exit codes have changed, but the ones you probably use should be the same. At the moment they're only documented in the code
- Flow understands the value of a negated number literal
Likely to cause new Flow errors:
- Some module exports that didn't require annotations before may now require annotations
New Features:
- Let/const support! Finally! (Huge props to @samwgoldman...again :] )
- Support for
mixins
ondeclare class
library definitions
Notable Bug Fixes:
- Improvements to types inferred from switch cases that fall through to a default cause
- Further improvements on symlink support
Misc:
- Significant performance improvements (both for initial start-up time and running re-calculation time)
- Improved
--traces
output
Likely to cause new Flow errors:
- Flow now treats class identifiers as being let bound. You cannot refer to a class before it is defined.
- If you accidentally use a tuple type instead of an array type for a rest param then Flow will complain
- You cannot use
this
beforesuper()
in a derived constructor, per ES6 semantics - Our dictionary property (aka indexer property) support is much more robust and catches things it previously missed.
- We weren't properly enforcing optional properties in
interfaces
anddeclare class
. Now we are.
New Features:
- Generators support, courtesy of @samwgoldman
- The number of worker processers is now configurable, defaults to the # of CPUs
- If Flow knows the value of a boolean expression, then it will know the value of that expression negated.
- Flow can remember refinements for things like
if(x.y[a.b])
export type {type1, type2}
syntax
Notable Bug Fixes:
- Fixed issue where Flow would still read package.json for [ignore]'d path
- Fixed some leaky annotations that let data flow through them
- Fixed instance and class types to be considered truthy
- Flow still initializing message now fits in 80 chars, compliments of @spicyj
- No longer will report hoisted declarations as unreachable code
- Fixed issue with how Flow chooses its tmp dir
- An async function can return a
T
or aPromise<T>
and it means the same thing - Fixed Flow forgetting about optional properties after an assignment refinement
- Fixed parser issue around future reserved keywords
- Optional parameters and rest parameters now work better together
Misc:
- Updated error locations. We've spent a lot of time auditing our error locations and trying to move them closer to the actual errors.
- esproposal.decorators option to tell Flow to parse and ignore decorators
- Bunch of updates to the libraries
- Some perf work
- Test output is colorized
Likely to cause new Flow errors:
- Assignment now triggers a refinement. If you have a variable that is a
?string
and you assign 'hello' to it, Flow refines its type to 'string'.
Likely to fix old Flow errors:
- We now treat missing type parameters as
any
. For example, previouslyReactElement
was treated asReactElement<*, *, *>
. Now it's treated asReactElement<any, any, any>
.
Misc:
- Basic unsafe support for getters & setters, gated behind the config option
unsafe.enable_getters_and_setters
- Support for block comments inside of Flow's comment syntax
- Disable by default munging of class property names that start with an underscore, with an option to enable it
- Lots of small internal fixes and merged PRs
- Basic semver support for the .flowconfig version
- Support for
declare type
in lib files - Type annotations are now opaque - other types will not flow through them
- You can configure the tmp dir that Flow uses
Likely to cause new Flow errors:
- Restricted
+
and+=
to only allow strings and numbers, and no longer implicitly cast objects, booleans, null or undefined. UseString(x)
to explicitly cast these values. - Fixed a few bugs where types shared between modules may have lost precision or weren't enforced.
Misc:
- Added
import typeof
feature that allows you to import the type of a value export from another module. It is sugar for:import MyThing_tmp from "MyModule"; type MyThing = typeof MyThing_tmp;
(except it removes the need for the intermediateMyThing_tmp
variable) - Added
flow ast
command to print a serialized JSON ESTree AST. (Note that this AST does not include types, just syntactic structure for now) - Added support for class expressions
- Added support for following symlinks
- Added support for number-literal and boolean-literal annotations. (useful for things like enum types and refinements based on tests of equivalence between two variables)
- Added support for ES6 binary and octal integer literals
- Added support for
export type
within a CommonJS module that also uses themodule.exports = ...
pattern - Added support for refining some union types down to their disjoint members
- Added support for covariant Promise type parameters
- Added improved support for understanding ES5-style imperative class definitions (i.e. via functions + prototypes)
- Fixed passing
undefined
to optional parameters - Fixed return-type tracking for tagged template usage
- Fixed an issue where library parse errors would cause the flow server to continuously restart upon initialization without giving an error
Likely to cause new Flow errors:
- Fixed a bug where declarations from libraries which are exported from one module are not checked properly in the module into which that module is imported (e.g. if
A.foo()
returns aPromise
, and module B requires A and callsA.foo()
, the return type ofA.foo()
was not being checked properly) - Fixed enforcement of Object and Function type annotation arity, so that
Object<K, V>
errors - Restricted valid computed properties, such that only strings and numbers are allowed (notably, disallows
null
andundefined
)
New features:
- Added support for
for-of
and support forIterable
interface(s) - Added support for
async
/await
- Added structural subtyping for interfaces -- anything can be an instance of an interface as long as it looks right
- Added support for type annotations of the form
typeof x
, wherex
is the name of an in-scope variable - Added a new config option
suppress_comment
, a regexp which matches against comments and causes any Flow error on the next line to be suppressed. For example,suppress_comment=.*\$FlowFixMe.*
will cause/* $FlowFixMe */\nvar x : number = "oops";
to not raise an error. - Added a new config option
module.name_mapper
, a regexp -> replacement template tuple to be applied to any matching module names before the Flow system resolves the name and looks it up - Added a
--color=always|never|auto
CLI option, useful when piping toless -R
- Added a
--one-line
CLI option which replaces\n
with\\n
in multiline error messages, useful when piping togrep
Misc:
- Many improvements to library files, especially node and ES6 APIs
- Improved warnings on unsupported class members [PR #461]
- Added support for
export default class
- Fixed
if (x instanceof Array)
- Fixed the type of
x && y
whenx
is an array, object or function - Fixed the
flow get-def
command, especially around imported types - Fixed a bug with
==
and improved comparison-related error messages - Fixed file watching for individual files included via .flowconfig [includes]
- Fixed the build ID, so that the server restarts when accessed from a mismatched client version
- Added a new config option
log.file
which overrides the default log file path
- We are now syncing Flow's commit history to GitHub. No more huge updating diffs. We'll also filter the changelog to the most important things.
- Big React refactoring to support ES6 React classes
- Do you use
any
to workaround things that you want to fix later? Well, now you can use$FixMe
instead ofany
and easily grep for these workarounds later. - We now report parsing errors in non-@flow files that you are
require()
'ing/import
'ing - Better error messages and better error message positions
- Better error traces, with
flow check --traces N
, whereN
is the trace depth - Basic support for
Object.freeze()
- Assorted fixes and updates to the flow libs
- We're trying to be better about commenting the code
- Bump version to 0.10.0
- Support import/export type
- [PR #412] More fs implementation
- Support for static overloads
- Fix order of args matched with overloads
- Allow methods to have properties
- [PR #405] Make interface-defined modules work with CommonJS/ES6Module interop
- Refine mixed
- Fix typeof null === "object" refinement
- [PR #397] Facilitate debug builds
- [PR #401] Improve error message clarity in a few places
- Remove 'everything is a bool' implicit cast
- Fix issues with optional properties during InstanceT ~> ObjT
- Fix abnormals in catch blocks
- Fix lowercasing issue where "flow Path/To/Root" became "flow path/to/root"
- Fix "My Path/To Flow/flow path/to/root" not autostarting server due to spaces
- Unbreak the command line for "flow path/to/root" (thanks samwgoldman for the report!)
- Bump version to 0.9.0
- Add Video-, Audio and TextTrackList (+ dependencies)
- Refine switch cases
- Better Not_found error
- [PR #333] Partial fs module implementation
- Update parser to match esprima-fb
- [PR #370] Dom canvas context
- [PR #393] Symbol should be called statically. Fix #391
- Fix havoc_env to copy the
for_type
value - add bash completion
- rewrite all the commands to use CommandSpec
- json_of_t
- [PR #384] Env printer
- [PR #383] Add some build/test artifacts to .gitignore
- [PR #377] Add missing HTMLImageElement properties
- [PR #367] Re-add merged out oneOfType proptype implementation
- Allow users to pin their .flowconfig to a specific version
- colorize test failure diffs
- Object spread fix
- [PR #322] Add type signature for node "url", "querystring" and "path" modules
- command parsing library
- look for package.json in include paths
- clear module errors properly
- add verbose mode
- Bump version to 0.8.0
- [PR #356] Add React.version to lib/react.js
- [PR #331] node http.get() implementation
- Fixes for indexers in object types and objects used as dictionaries
- Flow server speedup
- Support both commas and semicolons in object type patterns
- Fix object assign for unresolved objects
- Add prerr_endlinef
- Fix support for the mixin pattern of specifying super
- Incremental typechecking fix
- Fix up promises interface definition + more tests
- Perf win by loading master_cx once per job
- Support for-in of null and undefined
- Support typeof x === 'boolean'
- Refine true and false literals
- Fix refinement unit test
- Type declarations for Geolocation interface
- [PR #321] Support for React.cloneElement in 0.13
- Refine simple assignments (things like while (x = x.parent) { x.doStuff(); })
- Bump version to 0.7.0
- Initial support for ES6 import/export (with CommonJS interop)
- Updates to CSS/CSSOM interface definitions
- propTypes in React components now dictate the concrete type signature for this.props
- Show errors in type-at-pos output
- Flow now watches include paths specified in .flowconfig for file changes
- Interpret
x != undefined
andx != null
as the same refinement - Use Object.prototype.hasOwnProperty() calls as a refinement
- Updates to Element and HTMLElement interface definitions
- Bump version to 0.6.0
- Also watch for changes in include paths
- Fix the Function type to be any function
- Add Symbol global name to libs
- Support trailing commas in parser
- Make methods immutable
- Remove tuple array length limit
- [PR #315] Implement more PropTypes
- Update componentWillReceive spec
- Unsuppress library errors
- Bump version to 0.5.0
- Add HTMLAnchorElement
- [PR #295] Add one of proptype
- Update the parser to work with the new esprima-fb & ast-types
- [PR #299] Declare prompt function (fixes #204)
- [PR #303] Add String.prototype.endsWith()
- quick fix for react/es6 notation
- extend scope of type params to following bounds
- reasonless shortcut
- Add React.findDOMNode to lib/react.js
- move command documentation into each command
- fix path in --help usage example
- fix predicate filtering of null and undefined
- [PR #292] Types for React synthetic events
- basic support for bounded polymorphism
- infer falsiness
- node haste module support
- add Abnormal.string
** Flow comments should be ready for use **
- Bump version to 0.4.0
- [PR #259] Add declaration for Document.execCommand()
- [PR #265] flow status --json should exit 2 on errors
- Fix issue with switch statement breaks
- abnormal exit effects of fall-through cases in switch
- Let AnyObjT flow to KeyT
- invariant(false, ...) always throws
- Improve the "Object" annotations
- sealed object literals
- fix return types which could be undefined
- Support type annotations in comments
- [PR #263] disable colors when TERM=dumb
- Add lint checks for TRUE / FALSE / NULL
- class subtyping
- array literal inference
- Add unsafe_xhp typechecker option
- work around false positive conflict markers
- Better dumping types for debugging
** Type casts and import type should be ready for use **
- Bump version to 0.3.0
- Move haste module name preprocessing into module_js
- [PR #260] Add SyntheticEvent to lib/react.js
- Add import type to Flow
- [Parser] Add esprima tests for typecasts
- Add support for a module name preprocessor that can re-write require()d module names
- [Parser] Support import types
- Allow absolute paths for [libs] and [include]
- prepare flow-parser to be published to npm
- [PR #247] Resubmit #113 this fixes #155
- [PR #246] Fixes #195
- Bump version to 0.2.0
- Fix refinement of optional nullable types
- Typecast expressions (warning - not added to strip out transform yet)
- treat throw as similar to return
- Switch from React to react (React still included until facebook/react#3031)
- Fix types for sessionStorage and Storage
- tighter type for undefined values
- no lib paths fix
- Fix exporting types for builtin modules
- Add Number.isNaN and Number.isSafeInteger type annotations
- Optional properties in objects & optional type revamp
- Bump version to 0.1.6
- declare modules that redefine exports instead of exporting multiple things
- Object spread race condition fix
- Fix fallback path to flowlib.tar.gz
- [Parser] Type grouping bug fix
- Add Object.is
- uncomment
delete
method signatures - Add MAX_SAFE_INTEGER and MIN_SAFE_INTEGER to Number
- make param annotations strict upper bounds
- Bump version to 0.1.5
- [PR #223] from commonlisp/master
- [PR #221] from teppeis/Javascript-to-JavaScript
- Better types for React.PropTypes
- Make React a module
- Check PropTypes as a normal object too
- Better support for object call properties
- Add range/offset information to Ast.Loc.t
- ignored react attributes key & ref passed in spread properties
- ignored react attributes key & ref
- Add some checks when upper bound object type has indexer
- fix type arg arity exception
- add traces to .flowconfig
- fix error message when undeclared prop is set by jsx
- [Parser] Actually test ArrayTypeAnnotation
- Fix problem with returns in catch
- JSX with spread attributes
- Incremental mode fix
- Add missing constructors to TypedArray declarations
- [Parser] Update Flow's test suite to match updated esprima
- Bump Flow version to 0.1.4
- [Flow] Unbreak the open source build
- [PR #200] from fmahnke/node_http_interface
- [PR #203] from rsolomo/node-net-isip
- [PR #201] from unknownexception/patch-1
- [Flow] Fill out Map definition
- try-catch
- missing annotation errors for type aliases
- Type refinement fixes for early return
- Handle strict undefined checks.
- Add theoretical support to print tuple types properly.
- Relax the callback type in Array.prototype.forEach
- Add basic autocomplete support for React classes.
- [Hack] Kill shell.ml entirely.
- Handle spread attributes in JSX syntax.
- [Parser] Allow most keywords as types
- Add Array.from to lib file
- [#161]: String literal keys for object type aliases
- Generalize mock module handling under Haste a bit.
- Improve autocomplete type printing
- misc cleanup
- [Parser] Improve type keywords
- [Parser] Stop vendoring in ast-types
- Add an ocaml wrapper for find path1 ... pathN -name pattern
- Restart if a known lib file changes
- Add ProgressEvent definition and update two onprogress types
- [Hack] Add client time to server start time.
- Improve control flow type refinements
- [Hack] Reduce dependencies on ParserHeap.
- Exit server on config change for now rather than restart to avoid some bugs
- [Parser] ArrowFunction object & array patterns must be wrapped with parens
- Properly functorize logging code too
- [Hack] Make GC parameters configurable.
- Refinements on method calls
- [Hack] Log whether we are loading from a saved state in INIT_END.
- [Hack] Improve error handling for saved states.
- [PR #137] from sverrejoh/master
- [PR #150] from unknownexception/fix/dom.js
- [PR #146] from k-bx/master
- [PR #151] from unknownexception/feature/no_flowlib
- [PR #144] from rsolomo/node-assert
- [PR #191] from Shraymonks/HTMLBaseElement
- [PR #145] from rsolomo/node-util
- [PR #192] from Shraymonks/HTMLScriptElement
- Add ES6 String.prototype.contains
- Add Promise.prototype.done() to Flow lib
- [#78] Fallback to index.js if no main attribute in package.json
- [#82] Added ES6 functions to the Math object
- [#94] Start a node stdlib interface file
- [#98] Declare optional parameters according to HTML standard
- [#108] Add buffer class to node.js interface
- [#115] Some more node std libs
- The module system can now be specified in the .flowconfig file
- Libraries can now be specified in the .flowconfig file
- Multiple library paths can be specified
- Added a command to typecheck a file passed on standard input (for IDEs)
- Added HTMLInputElement to the standard library
- Improvements to type printing in flow suggest and other commands
- Fixes to various issues where parser errors were being suppressed
- [Issue #4] Typecheck .jsx files
- [Issue #22] Return a nonzero exit code from 'flow check' if there are errors
- [IRC report] Autostart the Flow server on all commands
- Improve the printing of types in 'flow suggest'
- Add a --timeout option to all commands
- [PR #27] Clearer error message when 'flow init' hasn't been run
- [PR #39] Fix to Emacs bindings
- [PR #53] Support node modules that end in .js
- [PR #59] Fix example
- [PR #65] Fix dependencies in flux-chat example
- [PR #66] Add type definitions for HTMLCanvasElement
Initial release