Likely to cause new Flow errors:
- Builtin idx support is removed. idx functions can now be typed with conditional type and mapped type. The v3 release of idx contains these typing changes.
- When using
module.system=haste
, it will now be an error if a.js.flow
file shadows a.js
file with a different path prefix.
Notable bug fixes:
- Fixed a bug that used to cause spurious internal errors when you have non-binding patterns. example
Parser:
- Fixed parsing of multiple
as
/satisfies
casts in a row.
Library Definitions:
- Added support for
Intl.Locale
class
Likely to cause new Flow errors:
- Flow is now stricter with regards to type checking of spreads,
$NonMaybeType
, and$ReadOnly
. You might see new errors revealed as a result. - Experimental utility types
$Pred
and$Refine
have been deleted. These are replaced by type guards.
New Features:
- Updated
Pick
andOmit
to work on interfaces and instances. - Conditional types, mapped types, type guards, and tuple enhancements are now enabled by default.
Notable bug fixes:
- Prevented hover and go-to-definition requests that infinitely loop.
IDE:
- For imported names using
require
, go-to-definition will now jump to the location of the original definition's name.
Notable bug fixes:
- Improve fuzzy matching of autoimports
Likely to cause new Flow errors:
- We fixed an issue where the intersection of two identical object types are turned into empty in spreads. As a result, more errors might be revealed. example
Notable bug fixes:
- We fixed an eager evaluation bug that can lead to some bad interactions between conditional type and mapped type. (example)
Parser:
- We fixed the parser size regression since 0.210.0.
Library Definitions:
- We rewrote the
Omit
type implementation. Now it will preserve the optionality and the variance of the input object. example
Notable bug fixes:
- Fix a bug where autocompleting a keyword deleted the next 7 characters on the same line
- "Fix" sorting of autoimports. An experimental option (
autoimports_ranked_by_usage=true
) to sort autoimports by how often they are imported was influencing the sorting even when the option was not enabled. This was likely an improvement, but it was a bug to not obey the option.
Misc:
- Improvements in preparation of new feature rollout
Likely to cause new Flow errors:
- We further strictified React.Element and React refs related typing. You might also see some existing errors related to React.Element and React ref moved around. Example
New Features:
- Added Pick, Omit, and Record utility types. [try-flow]
Notable bug fixes:
- Fixed a bug where
void
would appear in autocomplete suggestions more than once
Misc:
- Improved keyword autocomplete ordering
Parser:
Library Definitions:
- Added missing CSSOM
replace
andreplaceSync
- Added
arrayBuffers
to Node libdefs forprocess.memoryUsage()
's return type
Misc:
- Bug fixes in preparation of new feature rollout
Likely to cause new Flow errors:
- We removed support for React PropTypes. All related Flow builtin types like
React$PropType$Primitive
are deleted. React has deprecated PropTypes since v15.5. - We will now catch errors related to generic indexed access types. Example
- Fixed issues with indexed access on interfaces/instances. Access with string literals will now access named properties. example
- We now require annotation for computed access of instances, when that access is directly exported.
- The return annotation of a function can now reference a parameter name (e.g try-Flow). This may cause new errors if the return type used to reference a name that aliases a parameter name. This will now be captured by the parameter and cause a [value-as-type] error.
- We now error when using the name of a variable in its own annotation (e.g.
const x: typeof x = ...
). An exception is when the name of the variable appears under an object type constructor. For example, the annotationconst o: { f: typeof o } = ...
is allowed.
Notable bug fixes:
- Fix a bug in the previous version that makes declare let/const function scoped. We fixed it to be lexically scoped again.
Library Definitions:
- Array.flat will now have better typing support for flattening heterogeneous inputs.
e.g. [1, [1,2]].flat()
will now correctly have inferred type ofArray<number>
. - We added support for the following builtin types that are also found in TypeScript:
Notable bug fixes:
- Fixed a crash when we are trying to produce a quick fix for missing imports. The autofix for missing imports broken in the previous release would be working again now.
Likely to cause new Flow errors:
- Flow will now error on unsupported statements in library definitions, instead of silently ignoring them.
- Flow will error more consistently when variables of type any and empty are used as types (e.g. try-Flow)
IDE:
- Get definition request will now consistently jump to the name of the definition for ES module exports.
- In find local references, if a reference appears in a named import, it will no longer highlight the entire import as reference. Instead, it will only highlight the relevant name.
Notable bug fixes:
- Parameter types can now refer to previous parameters in the same parameter list (e.g.
function f(x: number, y: typeof x) {}
) - Report error when a function parameter is redeclared in its body in functions that have default params (e.g. try-Flow)
- For all declared names (declare class/var/let/const), we will allow full forward reference. All reads of these values will be considered to be initialized.
Misc:
- Changed React.Element to support a second type argument, as supported by React$Element
Library Definitions:
- Updated dom libdefs to allow Trusted Type objects
Likely to cause new Flow errors:
- When you pass a generic component type to some React utility type like
React.ElementConfig<typeof some_generic_component>
, we will replace all the type parameters with their defaults or bounds. It can potentially cause downstream errors. (Example)
New Features:
- Add built-in (intrisic) element names like
div
to JSX autocomplete - Mapped types now support operating directly over keys, like TypeScript's Pick and Omit (Example). Mapped type support is still experimental; enable
experimental.mapped_type=true
to try them.
Notable bug fixes:
- Don't check
@noflow
files in "all" mode - Fixed a source of spurious errors when using refined string keys as computed properties in objects (Example)
- Improved Go to Definition on
export
statements
Library Definitions:
- Added
rel
as an attribute toHTMLFormElement
- Added
WeakRef
class definition - Added
ariaHidden
DOM property
Likely to cause new Flow errors:
React.Element
will now accept a second type argument that specifies the props type. JSX will populate this type argument with actual props passed to component, instead of deriving it from the signature. The change will reveal some broken code, e.g. try-Flow example.$Shape
is deprecated, usePartial
instead. Read this blog post for more.- Add a (temporary) option
tuple_enhancements
to gate our tuple type enhancements (labeled tuple elements, which can be optional or have variance annotations), so we can show a Flow error rather than having users just get syntax errors from various other tooling (e.g. Prettier, ESLint), until all that tooling is updated. experimental.abstract_locations
is removed. Setting this config to true improves Flow's performance. The config defaults to true since 0.139.
New Features:
- Allow opaque types with
string
supertypes to be used as keys in a dictionary, and have that opaque type be preserved when usingObject.keys
. - To help people familiar with TS, error on and supply a quickfix to the Flow equivalent for the TS types:
Readonly
,ReadonlyArray
,ReadonlyMap
,ReadonlySet
,NonNullable
.
Notable bug fixes:
- Error more consistently with
[invalid-computed-prop]
errors. try-Flow. - Fixed cases where uses of
Partial
/Required
caused errors to be positioned poorly.
Misc:
- To improve clarity of error messages we will display
mixed
instead of a generic type if that generic type has a default bound ofmixed
. try-Flow. - Object property type incompatibility errors will now contain additional explanations when the error only arises due to object property invariant subtyping.
- Fix over-eager IDE autocompletion of types after typing a space.
Likely to cause new Flow errors:
- Remove the
flow get-imports
CLI command. - Some duplicate errors with
Arrays are invariantly typed
explanations are now correctly removed.
New Features:
- Added type-aware autocomplete in IDE for switch cases.
- Added signature help to IDE for constructor calls.
- Go-to-definition in the IDE can now provide multiple options if the target is defined in multiple locations (for example, in a union).
- Add
Required
andPartial
to list of utility types to autocomplete in the IDE. - Added quick fix in the IDE for missing "this." on class member access.
- To use the extract to expression/type alias IDE refactors, you no longer need to do exact selections to trigger it. Any selections that include extra whitespaces will be OK too.
Notable bug fixes:
- Fix go-to-definition in IDE for constructors (e.g.,
new Foo()
). - When considering a function as a callable object type, we now also check the statics of the function against the object. This may cause new errors. For example, the code in this try-Flow will now error.
- We now error more consistently when nested union types are being spread. Before, a bug was causing legitimate errors to not be surfaced. Example with [cannot-spread-inexact] errors: try-Flow. Example with type incompatibility: try-Flow.
- Some spurious underconstrained-implicit-instantiation errors might be removed. Previously, some classes that extend
any
might have caused this issue. - Fix over-eager IDE autocompletion of keywords after typing a space.
Library Definitions:
- Added NodeJS
process.hrtime.bigint()
. - Many built-in react components and intrinsics props are now readonly.
Notable bug fixes:
- Fix a crash that could happen when canceling a recheck during module resolution
Likely to cause new Flow errors:
- Some heap refinements might be invalidated more aggressively, when method calls appear in conditionals. This brings us closer to what happens in the case of the regular function call. (Example)
- Always error on the deprecated existential type
*
, it's just an alias forany
New Features:
- Experimental support for Mapped Types like
{[k in keyof T]: ?T[k]}
! (Example). Look out for a blog post, documentation and support in other tools in the near future. You can try mapped types in your project by setting theexperimental.mapped_type=true
flag in theoptions
section of your flowconfig.
Notable bug fixes:
- Fix autocomplete for super members (e.g.,
super.|
) - Fix hover type of JSX attribute names
- Fix showing documentation in signature help for member expressions (e.g.,
o.m(|)
) - Fix
unused-promise
lint false positives for logical and conditional expressions - Fix spurious error in overloaded generic calls when a contextual type is available (Example)
- Properly remove the
:
with inferred predicates inflow-remove-types
Parser:
- Error on classes with
static prototype
fields - Fix missing parse error for class constructors that are async, generators or accessors. The former two were previously type errors rather than syntax errors.
Library Definitions:
- Add NodeJS stream promises (thanks @moroine)
Misc:
- Add useful information to poorly located error messages. For example, for code like this try-Flow where the error points to a library definition, the error message will show the file that caused the error.
Likely to cause new Flow errors:
$Partial
has been renamed toPartial
, use the latter instead. Read the blog post for more details.- Support for
inference_mode
config and related infra such as codemods were removed. You should follow the instructions in the Local Type Inference for Flow blog post to switch to use LTI before upgrading if you haven't already done so. - We replaced the implementation which checks nested
$Call
and$ObjMap
during the check of a polymorphic function call. As a result, more underconstrained errors or type incompatibility errors might appear. - Removed the
sharedmemory.log_level
flowconfig option and the--sharedmemory-log-level
command line option.
IDE:
- Implement linked editing for JSX elements.
- Added code actions for adding/removing braces from arrow functions.
- Adds a quick fix from the deprecated
$Partial
toPartial
.
Notable bug fixes:
- Fixed a bug that caused instances of nested utility types to be considered equivalent to
empty
. e.g. try Flow example. - Make Flow's behavior more consistent by not erroring on
.constructor
accesses. e.g. try Flow example. - Fixed the file watcher not reacting to any changes on Windows.
- Improve the error messages when
underconstrained-implicit-instantiation
errors are raised in overloaded function calls. e.g. try Flow example - We now propagate
any
to instance types' type arguments. As a result, some spurious errors under LTI might be fixed (e.g. try Flow example), and some new errors might be revealed. - Fixed the hover type result when an enum object type appears nested in another type structure. e.g. try Flow example.
- Fixed the hover type on certain kinds of union types. e.g. try Flow example.
- Fixed the hover type on class constructors.
Misc:
- Try Flow's behavior can now be configured.
Parser:
- Leading
(
,&
and|
are now included in intersection and union ranges, respectively. - Improve error recovery for mismatched JSX tags.
Library Definitions:
- Change
setState
in React lib defs to use$ReadOnly<Partial<T>>
instead of$Shape<T>
. - Make
$ReadOnlySet
entry type covariant. - Expand the
Performance
typing with theeventCounts
property, according to the W3C standard. - Adjust the type definitions of the
mark
andmeasure
properties onPerformance
interface according to the W3C standard.
Misc:
- Fix a crash when using
experimental.channel_mode=socket
on Windows
Parser:
- Add "ObjectTypeMappedTypeProperty" node for mapped types
- Change "ConditionalType" and "InferType" nodes to "ConditionalTypeAnnotation" and "InferTypeAnnotation"
Likely to cause new Flow errors:
- Don't error for tuple element type incompatibility if we have already errored for invalid tuple arity.
- Fix a bug that causes certain errors in annotations to be hidden. As a result, more legitimate errors might appear. Example here.
New Features:
- Add support for optional tuple elements, e.g.
['s']
and['s', 1]
are both valid values for[foo: string, bar?: number]
. - Add autocomplete for keywords to the LSP.
- Add a code action that inserts jsdoc on a function.
exact_by_default=true
is now the default value if the option is omitted from the.flowconfig
. Read this blog post for more details.
Notable bug fixes:
- Fix LSP rename command to consider aliased named exports.
- If a contextually typed parameter has a default, we will filter out
null
andvoid
from the inferred type of the parameter. This removes spurious errors like this. - Some spurious
prop-missing
errors might be removed. Example here - Remove some spurious internal errors of Flow. Example here
Misc:
- Add option for
module.system.haste.module_ref_prefix_LEGACY_INTEROP
in the config to allow migration from theautomatic_require_default
flag and to ES module syntax.
Parser:
- Include InterpreterDirective in the AST.
- Fix loc/range of postfix arrays that start with a parenthesis, like
(A | B)[]
. - Fix missing error when arrow functions have duplicate params.
Local Type Inference:
- Local Type Inference is a rewrite of Flow’s type inference algorithm. This change makes Flow’s inference behavior more reliable and predictable. It replaces a global inference scheme that Flow has relied on since its inception and that has often been the culprit of confusing action-at-a-distance behavior, in exchange for modestly increased type annotations. It is now enabled by default! See this blog post for more details on the new system and steps to upgrade your project.
Likely to cause new Flow errors:
- When a variable is initialized at declaration, subsequent assignment in a conditional branch will no longer cause later reads to get a union type. This is already the case if the variable is annotated. As a result of this change, you might get new type errors. Example
- When a variable is uninitialized or initialized to
null
, we use all the assignments to the variables as its initial type. We now no longer consider assignments from a child generic function. As a result, you might get newinvalid-declaration
errors. Example - Fix object value rest. It will now error if attempting to read a write-only or setter-only property (it reads while copying the properties). Additionally, the resulting rest object will no longer preserve read-only variance (as it is a copy).
- The type utility
$Partial
will now preserve the variance of the input object type's properties. For example, if the the input was a read-only object, now that output will also be a read-only object (with optional properties). string
andsymbol
are no longer subtypes of an interface- Error on
with
statements in non-strict mode. It was already a syntax error in strict mode.
New Features:
- A native Apple Silicon precompiled binary is now available via the GitHub Releases page. It is not yet available via flow-bin. Internally, we see about 2X faster performance than using Rosetta, and 4X faster performance than on actual Intel Macs.
- Add local variable renaming capabilities to the LSP
- Add "Find All References" functionality to the LSP for showing local references
- JSDoc autocomplete will automatically trigger after typing
/**
- Add option for automatically closing JSX tags in the IDE
- Hovering in the IDE now shows both the unevaluated and evaluated type of the target expression.
- Add
use_mixed_in_catch_variables
config option that makescatch
variables default tomixed
instead ofany
- Rename
$Partial
utility type toPartial
.$Partial
will continue working as an alias for at least one more version - use that period of time to codemod it toPartial
. - Add the
Required
utility type. It does the opposite ofPartial
: it makes optional properties required in object types. - Improve error when attempting to call
Object.values
on a Flow Enum, to point the user to using.members()
- Improve error when using
number
andboolean
primitives as a subtype of an interface - Improve error on tuple arity mismatch
Notable bug fixes:
- Fix a bug preventing annotation hints from being used in tagged template expressions. This fix may get rid of some
underconstrained-implicit-instantiation
errors that were otherwise impossible to fix. - Fix error when autocompleting the method stub for a function type without parameter names
- Document highlight in the IDE now correctly highlights destructured object keys
- Autocomplete can suggest literals when the target type is
$Keys
- Add codemod to convert usage of the
$Shape
utility type toPartial
. It is possible that this will create type errors that you will have to resolve. - Add codemod to rename
$Partial
toPartial
Misc:
- Remove
unused-promise-in-async-scope
andunused-promise-in-sync-scope
. They can be enabled withunused-promise
. - Remove
--evaluate-type-destructors
flag fromtype-at-pos
command - Add
flow save-state --scm
flag to ease creation of SCM-aware saved states
Parser:
- Fix missing decorators on class fields
- Make
infer
a reserved word in types
Notable bug fixes:
We fixed a bug that causes spurious Array is not an array
errors in try-flow. Example
Likely to cause new Flow errors:
- We now require all generic functions to be fully annotated to prevent generic-escape issues. Some escaped-generic errors will be removed with
missing-local-annot
errors on return type annotation positions. - Under LTI, we will no longer silently give unannotated parameters in destructuring assignment
any
type. Instead, they will be properly contextually typed. e.g. try Flow example. - Some additional errors might be revealed after a correctness fix in implicit instantiation. e.g. try Flow example
- The
exact_by_default
option is now required to be set in the[options]
section of the.flowconfig
. Add eitherexact_by_default=true
orexact_by_default=false
to your[options]
section. Previously the absence of the option was equivalent toexact_by_default=false
. In the future, we will make the absence of the option equivalent toexact_by_default=true
. Read more about the option here: https://flow.org/en/docs/config/options/#toc-exact-by-default-boolean. To create a valid new.flowconfig
, useflow init
. - Changes to type variable unification may cause new errors to surface or old errors to be shifted to new locations.
- Fixed a bug where an unannotated parameter does not cause a
missing-local-annot
error under LTI. e.g. try Flow example - Flow will stop emitting some spurious errors and uncover some hidden bugs under local type inference, as a result of removing a cache that no longer makes sense.
- The
this
type of exported classes' methods are no longer unsoundly typed asany
. As a result, more underconstrained implicit instantiation errors might show up in LTI. - Relational comparisons between dates and numbers are no longer allowed.
New Features:
- We added
flow autofix missing-local-annot
command that will try to add annotations to autofix allmissing-local-annot
errors in a given file. - We now provide autofixes in IDE for all
missing-local-annot
errors where we can locally infer a type. Previously, this kind of autofix is only provided for unannotated parameters. - Added an
unused-promise-in-sync-scope
lint which will detect unused promises in sync scopes (likeunused-promise-in-async-scope
does for async scopes). Enablingunused-promise
will enable both of these rules. The individual rules will be removed in a future release. - Pragmas (e.g.
// @flow strict
,// @jsx custom_jsx_fun
) are now supported in try-flow.
IDE:
- Added autocomplete for jsdoc comments on functions.
- Added autocomplete for
$FlowFixMe
comments. - Autocomplete will no longer suggest existing type names for type binding identifiers (e.g., in the name of a type alias).
Notable bug fixes:
- We will no longer warn about
missing-local-annot
when there is a proper typing context insuper
call. e.g.super(x => x)
will now pass type checking under LTI if the super constructor call expects such function. - Builtin types like
$ReadOnly
will no longer shadow your local definitions with the same name. - We will no longer emit spurious errors when we are doing contextual typing while trying to resolve an overload. e.g. try Flow example
- We fixed a bug that over-zealously uses contextual type information from sibling nodes to type generic function calls. As a result, examples like the following no longer error: try Flow example
- fixed a bug where optional chaining on a value typed as a type application would not filter out the null or undefined value. e.g. try Flow example
- Some spurious errors might be removed as a result of Flow doing proper cache invalidation.
- Fix sorting of auto-imports with the same similarity score and length.
Parser:
- Parse and error on JSX type arguments.
- Add custom parse error for abstract classes.
- Add custom parse error when attempting to use template literal types in Flow.
- Add custom parse errors for TS class visibility modifiers public/private/protected.
- Remove
function
as an alias toFunction
, and don't allowfunction
as a type name in general. (closes issue #9000).
Notable bug fixes:
- Fix crash related to deleted files in Haste
Likely to cause new Flow errors:
- Support for spread argument in the builtin special-cased $Compose function is dropped. If you need this, you can write it yourself:
declare function compose<T>(
fns:...$ReadOnlyArray<T=>T>,
): T;
- Flow now consistently disallows implicit coercion of dates to numbers. Prefer explicit conversion with
getTime()
. - When a type argument is inferred from type argument bound or default, and such inference causes error downstream, we will provide better explanations in the error message where the type is coming from. Examples in try Flow.
- We fixed a bug under LTI that causes us to incorrectly skip checking for some function expressions Example. Some previously hidden errors might be revealed.
- We fixed a bug that causes some empty arrays to be incorrectly inferred as
Array<empty>
under LTI. e.g.Array.from(nullableStringArray ?? [])
. As a result, previously hidden errors might be revealed. - Errors for bad == or === comparisons will now consistently show up. Previously, some errors might be hidden when some optimizations are hit, which heavily depends on the implementation details. Example
- More
missing-local-annot
error might be shown in cases when we cannot resolve overload. Example - We fixed a bug where an unannotated parameter does not cause a missing-local-annot error under LTI. e.g.
declare function id<T>(T): T;
id([(item) => 1]); // now errors
New Features:
- Improved behavior of string literal autocomplete. Results will be provided regardless of the quote style used, and extra quotes won't be inserted when one is already typed.
- Add support for
declare let
anddeclare const
. These work likedeclare var
, but follow the rules oflet
andconst
respectively.
Notable bug fixes:
- We will no longer emit escaped-generic errors for predicate function bodies.
$Compose
now works under LTI mode.- Remove spurious
illegal-this
error when a this annotation is used in contextual typing. - Under LTI mode, we will no longer emit spurious incompatibility errors in invalid predicate function like
function f({a: b}): boolean %checks { return typeof b === 'string'; }
. Instead, you will only get error on this unsupported syntax. - Fix type created by tagged template literals and
String.raw
. (Closes #7580. Fixes #5705. Fixes #2616.) - We will emit fewer
underconstrained-implicit-instantiation
errors, when we decide that using type parameter default or bound won't cause downstream errors. - Fixed a bug in LTI where some errors in utility types were not properly shown. Example
- Fix IDE services that stopped working while a file contained a setter with the wrong number of parameters.
- Fix an issue with lazy mode where deleting a file before the server starts did not check files that were depending on the deleted file.
Misc:
- Try Flow is now using the new local type inference algorithm.
Parser:
- Parse bigint object keys (but type checking is not support yet).
Notable bug fixes:
- Fix a crash on Windows
- Fix a bug that could possibly result in a crash
Parser:
- Fix bugs concerning
await
in async formal parameters (including a regression in 0.198.0)
- Fix a regression in 0.198.0 that can lead to a crash
Likely to cause new Flow errors:
- Implicit coercion of booleans to numbers is consistently disallowed. Previously, booleans could be implicitly coerced to numbers in addition expressions. Prefer explicitly converting booleans to numbers.
- Binary arithmetic errors are now reported on the expression rather than the operands, and use error code
unsafe-arithmetic
. keyof
,undefined
,never
,unknown
, andreadonly
are now reserved types. If you have a user-defined types of these names, rename them to something else.
New Features:
- TypeScript syntax helpers. To help people familiar with TypeScript syntax ramp up on similar Flow syntax:
- Parse and error on
keyof
type operator, recommending$Keys<...>
instead. - Parse and error on
undefined
type, recommendingvoid
instead. - Parse and error on
never
type, recommendingempty
instead. - Parse and error on
unknown
type, recommendingmixed
instead. - Parse and error on
readonly
applied to tuple and array type syntax. - Parse and error on usage of
in
/out
/in out
variance annotations. - Parse and error on
as
,as const
, andsatisfies
cast expressions.
- Parse and error on
- Add a codemod to fix underconstrained-implicit-instantiation errors only detectable under LTI. You can run
flow codemod annotate-implicit-instantiations --include-lti --ignore-suppressed --write .
Notable bug fixes:
- Fix a bug in LTI mode where some errors were hidden in implicit instantiation calls (e.g. Try Flow)
- Fix unsound behavior of sentinel refinement with unions of numeric types as tags (e.g. Try Flow)
- No annotation is required in LTI for callback parameters when the callee is a refined object member (e.g. Try Flow)
IDE:
- When typing in an object literal, entire method signatures from the object type will be suggested.
- Method signature autocomplete items are now visually distinguished from other kinds of autocomplete items.
- Fix manually triggering autocomplete on the last empty line of a file giving no results.
- Members from
Object.prototype
are no longer included in autocomplete results.
Parser:
- Fix parsing of
for await (async of ...)
(regressed in 0.197.0) - Fix parsing of
for (let in x)
in non-strict mode - Fix parsing of class fields named
static
- Fix missing parse errors on keywords containing escape sequences (regressed in 0.180.0)
- Fix missing parse error when using
await
as a parameter in an async arrow function - Fix missing parse error for
export { ReservedWord as ... }
- Fix incorrect parse error on
export * as ReservedWord from ...
, which is now allowed - Treat
&&
and||
as tokens when parsing types to improve error messages - Parse the argument of the
typeof
type argument as a value, not a type, as it is a value
Library Definitions:
- Add
Element.getAttributeNames(): Array<string>
Local Type Inference:
We are releasing a new inference mode called local type inference. You can enable this new mode in your codebase by adding inference_mode=lti
to the [options]
section in the flowconfig. We will describe more details on this inference mode in an upcoming blog post.
Likely to cause new Flow errors:
- Unannotated class properties initialized with null will now errors.
- We now require all generic functions to be fully annotated.
bool
is a deprecated alias forboolean
. Added adeprecated-type-bool
lint andflow fix --error-codes deprecated-type
codemod to help migrate toboolean
. This lint is also included in thedeprecated-type
lint; ifdeprecated-type
is enabled, you can opt out withdeprecated-type-bool=off
New Features:
- Tuple improvements:
$ReadOnly
utility makes tuples read-only. E.g.$ReadOnly<[string, number]>
is the same as[+a: string, +b: number]
.- Tuple elements can now have their variance annotated, when the element is labeled. E.g.
type T = [+foo: number, +bar: string]
creates a read-only tuple. - You can now label tuple elements (like TypeScript allows). The labels have no type-checking effect, they just help with self documentation (like indexer labels). When a function argument rest element is a tuple type, the labels work like parameter names in signature help.
- We now parse tuple spread elements, but type checking of this feature is still unsupported.
- These new features are now supported in Flow, but we have not upgraded related tools yet. For example, Prettier won't be able to format your code that uses variance annotations on tuples.
- Allow
mixed
orany
as an annotation to acatch
parameter (but not anything else) - When typing in a class body, method signatures from super classes and interfaces will be suggested to make overriding/implementing these methods easier.
Notable bug fixes:
- Improve the parser's error recovery when in the middle of adding type parameters.
- Trigger autocomplete in JSX tags, JSX attribute values, and private class fields.
- Improves performance of bigints in big union checks
Misc:
- Inferred recursive types are shown as
any
(instead ofV$n
) in hover types.
Parser:
symbol
is now a reserved typefor (async of [])
is now a parse error
Library Definitions:
- Updated
AbortController
andAbortSignal
signatures - Actually expose
ReactSetStateFunction
type introduced in the last release.
- Fix a bug that could cause IDE commands to fail while a recheck is ongoing
🎁 This is (hopefully) our lastsecond to last release of the year. Happy holidays! 🎁
- Improve performance when unions flow to intersections
- Fix a crash when using the experimental
saved_state.allow_reinit
option
- Fix some missing autocomplete results (regression in 0.196.0)
Likely to cause new Flow errors:
- Instead of
mixed
, type the result ofObject.values
andObject.entries
on a dictionary to be the dictionary values, andObject.entries
keys to behave likeObject.keys
. Closes #2174, #2221, #4771, #4997, #5838. - Ban array inputs to
Object.values
andObject.entries
. - Function's
name
andlength
property are now not writable. - Fix
Object.keys
,$Values
, and$Keys
on interfaces with indexers. - Delete
$Subtype
and$SuperType
utilities. - Delete
deprecated-utility
Flow lint.
New Features:
- An annotation is no longer required when exporting + expressions (e.g.,
export default (3 + 3 : number)
can now just beexport default 3 + 3;
).
Notable bug fixes:
- Fix unary and binary arithmetic operations on bigints being exported/imported across modules as
any
ornumber
. - Fix autocomplete of string literals in bracket syntax, after a quote has already been typed.
- Improve sorting of results when autocompleting types.
- Boolean CLI flags must now be
1
ortrue
to be truthy. Before, anything other than0
andfalse
was considered truthy.
Misc:
- Autocomplete results are now sorted case-insensitively.
- Autocomplete results are now sorted using a fuzzy score, in the same manner as VSCode.
Library Definitions:
- Add
ReactSetStateFunction
type alias in react. This is the type ofsetVal
inconst [val, setVal] = React.useState(...)
.
Misc:
- Adds an
--experimental.run-post-inference-implicit-instantiation true/false
CLI flag to override the respective experimental flowconfig option.
Misc:
- Improved performance for the experimental post-inference implicit instantiation checks.
- Add a quick fix for the
unused-promise-in-async-scope
lint which will insertvoid
. - Add
symbol
andbigint
to$NotNullOrVoid
- Add
findLast
toArray
definition
Likely to cause new Flow errors:
- Casting an enum to
empty
will now properly error, e.g.(E.A: empty)
.
New Features:
- Added a quick fix for the
unused-promise-in-async-scope
lint which will insertawait
. - Added support for a number of additional bigint features. These include allowing comparison (
<
,>
,<=
,>=
), update (++
,--
) and arithmetic operators (+
,-
,~
,*
) to be used with bigints. - Added
sketchy-null-bigint
lint to match the behavior of the othersketchy-null-*
lints for bigints. - Added Flow Enums support for
declare enum
anddeclare export enum
. Keep in mind that users need to have enabled Flow Enums if you wish to create library definitions that use them.
Parser:
- Switch to dune to build and install the
flow_parser
OPAM package. Some modules insrc/parser/
likeComment_utils
are newly available. - Decrease the size of
flow_parser.js
by roughly 25%, to 768kb. - Fix a bug where
declare opaque type
was parsed as anOpaqueType
when interned comments are disabled.
New Features:
- Add support for bigint. This includes the bigint type itself, subtyping with literals, libdefs, typeof, and sentinel refinement. For now, literal types are limited to 64 bit ints. Later changes may lift this restriction as well as implement support for operators.
Notable bug fixes:
- Fix a few bugs related to the Haste package resolver. The Haste resolver falls back to the Node resolver when resolving packages. It now obeys the
module.system.node.root_relative_dirname
setting when doing so. Also, scoped package names are now supported in the Haste module resolver. - Allow private readonly properties to be written to in constructors, just like regular readonly properties.
Misc:
- Update team members in CONTRIBUTING.md.
- When using
module.system=haste
, importing packages innode_modules
folders now obeys Node's resolution algorithm, rather than being able to be required from anywhere in the project.
Library Definitions:
- Add a default generic value for getOwnPropertyDescriptor.
Notable changes:
- The
exact_empty_objects
flag and theannotate_empty_object
codemod are now deleted, See https://medium.com/flow-type/improved-handling-of-the-empty-object-in-flow-ead91887e40c for more details. - We have announced in a previous blog post that we are working on a new inference mode in Flow. Now the inference mode is mostly working, but there might still be some bugs remaining. You can try it out by adding
inference_mode=experimental.lti
to your flowconfig.
Likely to cause new Flow errors:
- Unknown computed properties assignments are now completely banned. Previously, they were still allowed if the object is inexact.
cannot-resolve-name
errors now are emitted for every use of an undefined variable, not just the first.
New Features:
- Added an experimental flow lint for unused promises in async scope. You can enable it by adding
unused-promise-in-async-scope
in the lint section of your flowconfig.
Misc:
annotate-use-state
andannotate-use-callback
codemod commands have been merged intoannotate-react-hooks
4- Added an experimental "scm" saved state fetcher, which selects a saved state based on your currently source control revision.
Library Definitions:
- Added support for Array.prototype.at
- Fixed WeakSet type parameter bound to be
interface {}
Likely to cause new Flow errors:
- The
exact_empty_objects
option is now enabled by default. Details about this change and how to update your codebase are covered on our blog. - The
typeof X
type annotation now respects the initialization state ofX
: ifX
hasn't been declared it will be an error to get its type.
Notable changes:
- The
enforce_local_inference_annotations
config option was removed. To migrate your codebase, run the following codemod to add the required annotations:flow codemod annotate-lti
. More details on the changes are explained in the Requiring More Annotations to Functions and Classes in Flow blog post. - Literals can be suggested by autocomplete in more cases
- Fixed autocompleting specifiers in an import statement
- Fix a bug on Windows where the server would exit unexpectedly after
hg update
- Performance improvements
Note:
Due to large number of likely new Flow errors that will be introduced in the next release, we decided to create an extra release to ease the upgrade process.
We announced in the recent blog post that we would remove the enforce_local_inference_annotations
option in flowconfigs, as it became the default in v0.189.0. This change will be delayed to v0.191.0 instead.
Likely to cause new Flow errors:
- Flow will now error on indexed write to exact objects without indexed type.
- Flow now requires that the target of
extends
clauses in class definitions are either variables, casts, or member expressions, rather than allowing arbitrary expressions. - We fixed a bug in which type arguments were not passed to the type parameters of static callable methods.
- We unblocked constraints involving
any
and type applications likePromise<T>
, which may cause new downstream errors to be discovered.
Notable bug fixes:
- Fix a bug that can cause the Flow server to unnecessarily restart when Watchman restarts
Likely to cause new Flow errors:
enforce_local_inference_annotations
is now on by default. To migrate your codebase run the following codemod to add the required annotations:flow codemod annotate-lti
. More details on the changes are explained in the Requiring More Annotations to Functions and Classes in Flow blog post.
New Features:
- Class members can be suggested by autocomplete even if
this
is not typed explicitly.
Notable bug fixes:
- We will now consistently emit
object-this-reference
errors. Previously these errors were missing when the object is an argument ofObject.freeze()
,Object.defineProperties()
orObject.create()
. - Fix crash when walking directories that can't be accessed.
- Fixed a potential crash when two type identifiers are declared in the same block.
Library Definitions:
- Improve
fs.readFile
type definition when theencoding
config option is supplied.
Bug fixes:
- Fix crash during incremental recheck
Performance:
- Improve performance of auto-imports index update for large codebases
Bug fixes:
- Fix a crash when querying hg
Misc:
- We renamed the codemod command
flow codemod annotate-lti
toflow codemod annotate-functions-and-classes
to clarify that this is not the only codemod necessary for enabling LTI eventually.
Likely to cause new Flow errors:
- Previously we supported a weird JS runtime rule for constructor returns when you call
new SomeClass
:
- If the returned value is primitive, then it's ignored and the instance will be returned instead.
- If the returned value is object like, then the return object will be the eval result of
new SomeClass
. This is confusing, and we dropped support for this feature in this release. Now we enforce that all class constructors must return void.
- Fixed a bug preventing refinements from being invalidated in inline
&&
expressions: examples liketypeof x === 'number' && reassignXToString() && (x: number)
were passing even ifreassignXToString()
assigned a a string value tox
.
New Features:
flow codemod annotate-lti
is now provided to help prepare your codebase to enable theenforce_local_inference_annotations=true
flag. In order to eventually enable local type inference, we will require additional annotations in places we can't contextually type your code. You can enable the annotation enforcement now withenforce_local_inference_annotations=true
in flowconfig. This flag enables the behaviors of all the following experimental flags, which will be deleted in the next release:
experimental.enforce_local_inference_annotations=true
experimental.enforce_this_annotations=true
experimental.enforce_class_annotations=true
To migrate your codebase, you can run the following codemod to prepare your codebase for the new requirement: flow codemod annotate-lti
. Check out an upcoming blog post for more details.
Misc:
- Remove the
file_watcher.watchman.survive_restarts
flowconfig option, which was deprecated in 0.158.0. We will always try to survive Watchman restarts. - Remove the
experimental.refactor
flowconfig option. It has beentrue
by default since v0.158.0.
Library Definitions:
- Updates the typing of 'fs.promises.readdir()' to reflect the possibility of passing 'withFileTypes: true' and receiving an array of Dirent objects
- Fix a crash introduced in 0.187.0 when the file walker fails to open a directory
Likely to cause new Flow errors:
- JSX expressions in a file with jsx pragma of member expressions (e.g.
@jsx Foo.bar
) will no longer be incorrectly considered as unreachable. This might uncover previously hidden errors. - Functions statics (i.e. assigning properties to functions) are safer, but also a bit more restricted. Function statics should be assigned in the same statement list as the function (i.e. not conditionally).
New Features:
- When autocompleting in the middle of a word, autocomplete now inserts the suggestion, instead of replacing the entire word. For example, if you are completing in
foo|Baz
(cursor at|
) and choosefooBar
, you'll now getfooBarBaz
instead offooBar
. In VS Code, you can press shift-enter to replace instead of insert.
Bug fixes:
- Fix Go to Definition on certain kinds of import statements
- Improve location of error references pointing at imported namespaces (D38978756 mroch)
- Fix some missing references in CLI errors (D38977164 mroch)
- Improve location of error messages referring to
declare module
exports (D38977152 mroch) - Change
flow get-def --json
to write{"error": message}
to stdout on error, instead of writing non-JSON to stderr - Fix a garbage collector bug that rarely could lead to crashes
Library Definitions:
- Allow access of arbitrary properties from
import.meta
. They are typed asmixed
- Add support for MediaSourceHandle
Notable breaking changes:
- Support for
inference_mode=classic
has been removed. The default is nowinference_mode=constrain_writes
. Please refer to the blog post for migration paths. Additionally we have removed all codemod commands that depend on the classic inference mode. This includes theannotate-declarations
,rename-redefinitions
andannotate-escaped-generics
codemods.
Likely to cause new Flow errors:
- Exported functions can only have properties assigned in the same scope as the function.
- Improve behavior of index property access with union types (try-Flow example). May cause new errors in interaction with computed properties.
- Referencing
this
in object getters and setters are now banned. Referencingthis
in object methods are already banned, and this change makes Flow's behavior more consistent.
Notable bug fixes:
- Fixed a regression in destructuring checking with computed properties (issue).
Library Definitions:
- Added
PerformanceServerTiming
definition and theserverTiming
attribute toPerformanceResourceTiming
.
New Features:
- Flow now supports the
@jsxRuntime
pragma in the top docblock of each JS module. Allowed values areclassic
andautomatic
.
Misc:
- Improve the experimental mode to rank autoimport suggestions by how often they're imported (
autoimports_ranked_by_usage=true
)
Likely to cause new Flow errors:
- Unbound names in jsx-pragma when the jsx-pragma is not a simple identifier will now consistently point to the jsx pragma.
- Errors previously hidden by method-unbinding will reappear.
- Fix a bug that makes assignments in loop guards like
x = some expression containing x
have a type that's effectivelyany
. If you turned oninference_mode=constrain_writes
since the last release, there will be new errors. - Remove
esproposal_export_star_as
as an option and make this the default as it made it into the JS standard in 2018. - Additional
value-as-type
errors might be emitted, as a result of existing importing errors. - Object rest on instances no longer results in an unsealed object (that can have properties added after the fact)
New Features:
inference_mode=constrain_writes
will be the default.inference_mode=classic
, which is the current default, will be removed in the next release. Please refer to the blog post for migration paths.
Misc:
- Fix flow-remove-types/jest transformer to be compatible with Jest 28. (Thanks @carloscuesta)
- Add codemod to remove annotations in destructuring - which we banned in 0.176
Library Definitions:
- Add missing
.x
and.y
properties to DOMRect. (Thanks @pmer)
Upcoming Breaking Changes:
-
New Inference Mode:
We are releasing a new inference mode that marks significant progress on our way to local type inference. You can enable this new mode in your codebase by adding
inference_mode=constrain_writes
to the[options]
section in the flowconfig.We will make
inference_mode
default toconstrain_writes
in v0.185, and remove theclassic
option in v0.186. To migrate your codebase, you can run the following codemods to prepare your codebase for the new inference mode:flow codemod rename-redefinitions flow codemod annotate-declarations
We will describe more details on this inference mode in an upcoming blog post.
-
Additional Annotation Requirements:
In order to eventually enable local type inference, we will require additional annotations in places we can't contextually type your code. You can enable the annotation enforcement now with the following flags in flowconfig:
experimental.enforce_local_inference_annotations=true experimental.enforce_this_annotations=true experimental.enforce_class_annotations=true
To migrate your codebase, you can run the following codemod to prepare your codebase for the new requirement:
flow codemod annotate-lti-experimental
Likely to cause new Flow errors:
Object.create
now results in a sealed object. Arbitrary properties can no longer be read/written from/to it. You can use the__proto__
property in object annotations to create an annotation if you need to.
Notable bug fixes:
- Fix spurious object subtyping errors when an object literal is passed into rest arguments with tuple type
function emit(...args: [{+bar: string}]): void {} emit({ bar: "" }); // no longer emits incompatible-variance
- Fix a bug on Windows that could lead to a crash if files are changed faster than they can be rechecked
flow-upgrade
:
- Add a codemod to collapse multiline object initialization into one object literal - useful for enabling the
exact_empty_objects
flowconfig option
Library Definitions:
- Add DOMTokenList index signature
- Fix a regression in 0.183.0 on Windows where inconsistent handling of slashes within paths led to mismatches like "duplicate provider" errors
Likely to cause new Flow errors:
- We now emit new errors in places where an object literal has literal types, but doesn't have an annotation. You can usually fix these errors by adding annotations to object literals.
New Features:
- Allow export of empty object without annotation when
exact_empty_objects
is enabled. - Improve annotate
useState
codemod to supportnull
/undefined
/empty-array arguments.
Notable bug fixes:
- Allow flowconfigs with blank lines before the first config section.
- Fix location of error message about legacy octal number types.
- Fix inconsistent blank lines around auto-imports.
- Fix bug where Watchman events might be ignored on Windows.
Parser:
- Fix parser exception on negative binary and octal number types that contain whitespace after the minus sign.
Library Definitions:
- Improved
fs.readdir
andfs.readdirSync
to allow better overload resolution. - Add
String.prototype.replaceAll()
(Thanks @dav-s).
Likely to cause new Flow errors:
var
re-declarations are now banned. You should uselet
orconst
instead.- Flow will now emit escaped-generic errors when the return type of a generic predicate function contains type parameters defined by the function.
Notable bug fixes:
- Improve ordering of autoimport suggestions, so that globals are suggested above named imports.
Misc:
- Errors related to class expressions might have new locations.
- Fix the rendering of classes in autocomplete results
- Fix the ordering of class methods in autocomplete results
- Improve ability to recover from Watchman restarting (the fix in 0.181.0 was incomplete)
- Fix a bug where warnings would be incorrectly reported when using saved state, and could cause a crash.
- Add
--saved-state-verify
flag to check that a saved state matches what is expected to be on disk.
Notable bug fixes:
- The JS build for try-flow is now fixed. It's recently broken since the 0.181.0 release.
Notable bug fixes:
- Fix unsound spreading of empty array literals (example)
- Fix a race condition that could cause individual requests from the IDE to hang indefinitely
- Improve ability to recover from Watchman restarting
Parser:
- Fix parsing of invalid UTF-8 to raise the correct "Malformed unicode" parse error
- Fix line numbers when regex character classes contain an (invalid) newline, which could've led to a crash
Library Definitions:
- Add AudioContext constructor options
- Update Node's
v8
module
Notable bug fixes: Reverted changes that cause Flow to generate a corrupted saved-state when libdef changes.
Likely to cause new Flow errors:
- Generator functions without return type annotations now default the type of the
next
parameter tovoid
. If a non-voidnext
type is desired for a function, it will have to be annotated. - When
experimental.enforce_local_inference_annotations
is enabled, Flow now requires annotations on functions returned from async or generator functions. - Return statements that return objects no longer widen the object type to match the return annotation, if present. This may lead to additional errors, which can be addressed by adding annotations onto variables that are returned.
New Features:
- Optimize initialization from saved state.
- When
experimental.enforce_local_inference_annotations
is enabled, Flow now has a code action to auto-annotate parameters of functions that havemissing-local-annot
errors.
Notable bug fixes:
- Fix broken IDE services when the file contains certain invalid type annotations,
import type * ...
,export async ...
statements or nameless named exports. - Fix some potential deadlocks on Windows.
Misc:
- Add
--no-enums
flag toflow ast
.
Parser:
- Fix a runtime exception when parsing regexes via the JS version of the parser.
- Fix crash when the input is a lone quote.
- Fix missing syntax errors when functions with non-simple params contain
"use strict"
Library Definitions:
- Add type signature for
Navigator.canShare()
.
Likely to cause new Flow errors:
- Improve the type checking of function parameters that use destructuring, have an annotation, and also have a default value.
Notable bug fixes:
- Fix IDE services in the presence of certain types of parse errors.
- Fix crash when encountering an unexpected
\/
. This could have broken IDE integrations while typing. - Fix crash with invalid for-await loops.
Parser:
- Add parser support for ES2022
d
RegExp flag (see RegExp Match Indices).
Library Definitions:
- Add void to the React$Node type.
Notable Bug Fixes:
- [fix] Fix a crash during incremental recheck when an empty string import (
e.g. import ''
) is added. - [fix] Fix a stackoverflow caused by extremely large objects
- [fix] Fix an incremental update issue where Flow would sometimes resolve requires to stale Haste modules which have no provider files
Likely to cause new Flow errors:
- Improve type incompatibility error messages on default function parameters
- Invalidate refinements on calls of
require
, since requiring a module can have side effects
New Features:
- Add types for React 18 hooks:
useId
,useInsertionEffect
anduseSyncExternalStore
Notable bug fixes:
x instanceof A
whenx
is typed asany
refines it toA
instead ofempty
- Fix an issue with
[include]
entries containing both globs and relative paths on Windows - Fix crash when declaring a destructured binding in a library definition
- Fix missing autocomplete results for JSX component properties when the component's type is recursive
- Fix analysis of unreachable += expressions
- Fix incremental typechecking bug when adding files in Haste mode
Parser:
- Fix parser exception when parsing
export interface ...
orexport enum ...
Likely to cause new Flow errors:
- Fix a bug where refinements should be invalidated when going through multiple control flow branches (thanks @gnprice)
- Make catch parameters explicitely
any
typed - Ban object spreads of numbers and strings
- Fix a bug that makes Flow consider some function names to have the empty type
- Numbers, booleans, and enums are no longer subtypes of the empty interface
interface {}
- Previously incorrectly missing errors might appear in expressions of the form
name === 'literal'
andname.prop === 'literal'
complaining thatliteral
is incompatible with the type ofname
orname.prop
. - Update input type of Object.{values,entries} to be
interface {}
rather than$NotNullOrVoid
;number
andboolean
inputs will now error
New Features:
- Add codemod to add explicit type arguments to
useState
when it is called with an empty object. Use withflow codemod annotate-use-state
- Continue type checking files with indeterminate module types.
Notable bug fixes:
- Do not add further errors when we already errored on the illegal reassignment.
- Flow now checks whether
literal
is a subtype ofexpr
inexpr === literal
, regardless of whetherexpr === literal
can be applied as a refinement - Fix a crash when deleting a file or saving a file with parse errors in certain circumstances
- Fix a rare crash when files are deleted during rechecks
- Fix a parser bug that allowed missing commas between object properties (regression in 0.175.0)
Parser:
- Improve error recovery when in the middle of adding a property to an object type literal
Library Definitions:
- Add NotificationEvent to service workers API
Notable bug fixes:
- The Haste module resolver now chooses Haste modules before node_modules, to match what Metro does. That is, if you use
module.system=haste
and have both a@providesModule foo
file (or use "haste paths" to derive the module name from its filename) and anode_modules/foo
folder,require('foo')
will now resolve to the Haste module, even whennode_modules/foo
is in that file's parent directories. This is also a significant perf improvement because resolving a Haste module is much cheaper than searching for node_modules. - Fix several bugs responsible for crashes
- Fix bugs responsible for some LSP "server is stopped" errors
Revert changes that are causing bugs in non-lazy mode.
Fix crash when comparing abstract and concrete locations when simplifying normalized types.
Likely to cause new Flow errors:
- Banned usage of
new
on functions. Move usages of this pattern to use ES6 classes instead. If the pattern exists in third-party code that cannot be changed directly, you can use a declaration file to type the legacy pattern with adeclare class
. - Error on type annotations nested inside of destructuring - these were always invalid, we just ignored them before
Notable changes:
- Removed special support for
React.createClass
from Flow. It is now just typed asany
. Migrate any components using it to class components or function components. - Added the
module.missing_module_generators
option, which can be used (multiple times) to specify'regex' -> 'command'
pairs. When a module is missing, if its name matches one of the regexes, we will add a suggestion in the error message to runcommand
to generate it (and resolve the error). - Fixed bugs responsible for some LSP "server is stopped" errors
- Fixed a bug that could cause the server to become unresponsive on Windows
Bug fixes:
- Fix an incremental bug which would sometimes cause Flow to choose the wrong provider for a haste module, most commonly when one of those providers is a .js.flow file.
- Fix ability of
flow stop
to kill stuck servers - Fix rare crashes when processes exit unexpectedly
Notable changes:
- Improve error messages when using a type as a value
- Improve error messages in
for
loops - Correctly determine the scope of default expressions in function params
- Add
FLOW_CONFIG_NAME
env as alternative to passing--flowconfig-name
- Add
file_watcher.mergebase_with.{git,hg}
configs to support projects accessible via multiple VCSs (e.g. git mirrors of hg repositories)
IDE integration:
- Surface deprecated autocompletion results so they appear with a strikethrough in VS Code
- Fix a bug where changing libdefs, package.json files or the .flowconfig multiple times will cause the IDE to report "server is stopped".
- Fix a bug where the IDE is unable to start the server if it is downgraded
- Improve suggestions when autocompleting keys in an object literal
- Fix an exception when autocompleting a result that would add to an import to an existing
require()
flow-remove-types:
- Fix handling of
this
param with trailing commas
Fix crash when Flow receives duplicate file deletion notifications introduced in v0.174.
Likely to cause new Flow errors:
- Flow now detects sketchy null errors that arise via optional chaining, and which involve opaque types, type aliases, or generics.
- Fixed an issue that caused us to previously miss some errors when the type involved was an intersection.
New Features:
- Access from a union of exact objects, on a property that is on one but not all of the objects, now results in the type of that property or
void
, instead of an error. - Add type checking support for logical assignment operators.
Notable bug fixes:
- Fix a crash when using the default file watcher (dfind) on Windows if an [include] directory doesn't exist.
- Do not attempt to unify the type of a
declare
function that comes after a function declaration of the same name (try-Flow). - Improve wording of class-extends errors (try-Flow).
- Don't report
this-in-exported-function
for functions with athis
parameter.
Misc:
- Added
--list-files
flag tostatus
andcheck
commands. This will dump a list of files that contain errors instead of the error messages. - The default file watcher (dfind) now logs to a
.dfind_log
file alongside the.log
and.monitor_log
files. - Changed the way Flow computes coverage for type parameters with uncovered upper bounds. Previously, a type parameter was always considered covered when it appeared in a function signature, class declaration, or type alias, even if the type parameter's upper bound was
any
. With this change, such type parameters are now considered to be uncovered. This results in Flow now computing a lower coverage percentage on modules where this pattern is present or that import types from other modules that use this pattern.
Likely to cause new Flow errors:
- Modified the behavior of
instanceof
checks and other refinements to more consistently detect when impossible or invalid refinements are made. This will result in new errors in such cases.
New Features:
- Improved error messages by providing a suggested property when properties are missing in a conditional context.
Notable bug fixes:
- Fix "matching property" checks with generic inputs (try-Flow). Thanks @gnprice for bringing up this issue and exploring potential causes!
- Fixed a bug where the use of certain utility types in polymorphic functions caused errors to not be reported (e.g. try-Flow)
- Fix a bug where the [method-unbinding] error was reported twice
Misc:
- OCaml version 4.12.1 is required to build Flow
- React default exports are now inexact, as technically this can include unknown properties (experimental features)
Parser:
- Fixed a bug where type parameter instantiations that start with
<
(e.g.,f<<T>()=>S>()
) would be incorrectly parsed as the left shift operator.
Library Definitions:
- Add bindings for NodeJS
util.types
Bug Fixes:
- Exact objects are treated as truthy in logical expressions
- Add support for operations on
$Values<>
types in an export position (e.g. Try Flow) - Respect the order of
module.file_ext
when resolving imports. Before, they were tried alphabetically.
Misc:
- Change
signature-verification-failure
from a lint to a normal error. It is no longer valid in the[lints]
section of.flowconfig
. - Improve performance of IDE commands when Flow is busy typechecking
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 react-dom@16.13.0
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 #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 (#1327)
- Fixed an issue where an object of some intersection type could not be used with the spread operator (#1329)
- Fixed an issue where refinement-testing on an object of an intersection type wouldn't always work (#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