Changelog.md
Likely to cause new Flow errors:
+T, -T, in T, out T) on interface method type parameters, matching the existing rejection on class methods and function typesNew Features:
declare class and interface of the same name in the same scope.const A = 1; interface A {} is now accepted.New Features:
declare class and interfaceLibrary Definitions:
Record<K, T> utility type's key bound from K: string to K: PropertyKey, allowing number and symbol keys in addition to stringMisc:
experimental.allow_variance_keywords is set to true, we support the keywords in / out / readonly along with +/- for varianceNew Features:
new (...) => Type) in interfaces and declare classMisc:
allow_variance_keywords is set to true, Flow stops erroring for in / out / readonlyNo significant changes.
Parser:
EnumBooleanBody, EnumNumberBody, EnumStringBody, EnumSymbolBody, EnumBigIntBody) have been replaced with a single EnumBody node. Its members property is a flat array of per-type member nodes (EnumBooleanMember, EnumNumberMember, EnumStringMember, EnumBigIntMember, EnumDefaultedMember). The explicitType property is now a string ("boolean", "number", "string", "symbol", "bigint") or null (previously a boolean). hasUnknownMembers remains a boolean. Several enum validation errors are no longer reported by the parser and are instead reported by the type checker.Library Definitions:
RegExp.escape()Notable bug fixes:
infer to appear as member names in qualified type access (e.g. type S = O.infer;).readonly, keyof, infer, etc.) as function type parameter namesParser:
? optional modifier in various places this does not make sense, e.g. const x? = 1;Misc:
flow check becomes an alias of flow status. You can use flow full-check to trigger a full foreground check of a Flow root.New Features:
Symbol.iterator.Notable bug fixes:
Library Definitions:
Misc:
Notable bug fixes:
New Features:
stylex_shorthand_prop flowconfig option that enables syntactic sugar for StyleX on lowercase (intrinsic) JSX elements. When set to a prop name (e.g. stylex_shorthand_prop=sx), <div sx={[styles.foo, styles.bar]} /> desugars to <div {...stylex.props(styles.foo, styles.bar)} />.Notable bug fixes:
Misc:
IDE:
IDE:
React autoimport, it will now always be in the form of import * as React from 'react'Misc:
Parser:
export declare, like declare exportcomponent in implicit declare context, the ast we produce will include implicitDeclare: trueLikely to cause new Flow errors:
Parser:
filename in the option objectNew Features:
declare keyword can be omitted for declare function under declaration context (.flow file, declare module, declare namespace)Parser:
Declarations:
declare keyword can be omitted for declare const/let/var variable: type and declare component under a declaration context (libdef file, .js.flow file, declare module, declare namespace)declare component now requires the rest props to be named - matching normal component declarationsMisc:
Omit<O, K> utility type will no longer enforce that the provided keys K need to be part of ONew Features:
Symbol.iterator, Symbol.asyncIterator, Symbol.dispose, Symbol.asyncDispose) in class methods. For now, the computed method name needs to be exactly in the form of Symbol.iterator (or other 3 names) to be recognized.Notable bug fixes:
Misc:
yarn run flow-codemod convertLegacyUtilityTypes)Parser:
Parser:
Bug Fixes:
Config:
use_mixed_in_catch_variables option was renamed use_unknown_in_catch_variables because mixed is being renamed to unknownLikely to cause new Flow errors:
Parser:
IDE:
invalid-type-cast-syntax errors in the file.Likely to cause new Flow errors:
type O_loop = { p: 0, __proto__: O_loop } will cause an error.Notable bug fixes:
import { | } from 'a'; will only suggest values, not types.IDE:
Library Definitions:
Likely to cause new Flow errors:
$NonMaybeType, NonNullable, $ReadOnly, Readonly, $Keys, $Values, Values, $ReadOnlyMap, ReadonlyMap, $ReadOnlySet, ReadonlySet.Notable bug fixes:
StringPrefix/StringSuffix to be included in object initializers with other non-overlapping keys (example try-Flow)Library Definitions:
act: 19.0: https://react.dev/reference/react/actcaptureOwnerStack: 19.1: See https://react.dev/reference/react/captureOwnerStackuseEffectEvent: 19.2: https://react.dev/reference/react/useEffectEvent<Activity />: 19.2: See https://react.dev/reference/react/Activity
UpdateduseDeferredValue: 19.0: Accepts a second argument for initial valueuseTransition: 19.0: Accepts an async action functionstartTransition: 19.0: Accepts an async action functionLikely to cause new Flow errors:
React.ElementProps is removed. You should use React.ElementConfig instead.react-rule-hook-non-hook-syntax errors. To fix, annotate them with hook annotation. exampleReact$RefSetter<...> and and React$Context are removed. It continues to be available in the form of React.RefSetter<...> and React.Context<...>, regardless of whether you have imported React.React$ElementRef<...> was removed. It continues to be available in the form of React.ElementRef<...>, regardless of whether you have imported React.Breaking Changes:
max_literal_length was removed. Flow will always decide whether to infer a specific or general type of string literal based on the natural inference algorithm.Notable bug fixes:
@@dispose and @@asyncDispose in your library typings. You can access the respective properties with obj[Symbol.dispose] and obj[Symbol.asyncDispose].Library Definitions:
ExactReactElement will be populated by React.ElementConfig<C> instead of React.ElementProps<C>. Most of the code that doesn't depend on exact react element types won't be affected.Breaking Changes:
hermes-parser package, which is running on wasm.Likely to cause new Flow errors:
React$Element type is now removed. You should use React.Node or React.MixedElement in most cases. If you really want exact react elements, you can use ExactReactElement_DEPRECATEDNew Features:
IDE:
Breaking Changes:
flow-bin will only contain ARM64 binaries for macOS.Likely to cause new Flow errors:
React.ElementConfig<...> and React.PropsOf<...> will now always include the ref prop in the props object type.react.ref_as_prop=partial_support is removed, and Flow now has better support for React 19's ref-as-prop behavior:
declare function id<Props: {...}, Ref>(c: component(ref?: Ref, ...Props)): component(ref?: Ref...Props)
now it must be written as
declare function id<Props: {...}>(c: component(...Props)): component(...Props)
Library Definitions:
useActionState hook in React. Type should be Awaited instead of Promise (the opposite operation).Object.groupBy and Map.groupBy
Bug fixes:
experimental.ts_utility_syntax=true, imported Readonly, ReadonlyArray, NonNullable, ReadonlyMap, ReadonlySet types are considered any.Likely to cause new Flow errors:
Likely to cause new Flow errors:
// $FlowFixMe[incompatible will now cause an error on the suppressionLikely to cause new Flow errors:
Notable bug fixes:
<X>(x: X, y: typeof x): TIDE:
Library Definitions:
Array.find can now return a more precise value if the predicate is inferred to be a type guard. exampleBreaking Changes:
casting_syntax=colon is removed. This means that the as casting syntax is always enabled.experimental.error_code_migration config option is removed. In the previously version, the only allowed value was new.Likely to cause new Flow errors:
$FlowFixMe and $FlowExpectedError are supported suppression comments. Existing $FlowIgnore and $FlowIssue will no longer suppress anything.New Features:
require-explicit-enum-checks which works like require-explicit-enum-switch-cases but for match.Notable bug fixes:
class Foo extends myExpr() as Bardeclare) method in the same vs different files.IDE:
Likely to cause new Flow errors:
missing-export error instead of prop-missing error. (example)suppress_type $FlowFixMe is now just a type alias of any. For most of the code, there will be no functional differences. However, you might see new errors if you have any local definitions of $FlowFixMe, or you used the undocumented $FlowFixMe<arbitrary type arguments>.suppress_type config has been removed. The only supported supress_type now is $FlowFixMe. If you want other variants, you can addtype MySuppressType = any
in your global library definitions.
incompatible-type, so some previously suppressed errors will reappear until you change the suppression error code into incompatible-type. The change was announced in the previous version, with option to enable it via experimental.error_code_migration=new. Now the only valid option to experimental.error_code_migration is new. You can run flow codemod error-code-migration --write . with the previous version of Flow to help migrate, since the codemod is removed in this version.New Features:
incompatible-type. You can add experimental.error_code_migration=new in your flowconfig to enable the new behavior now. We also provide a codemod flow codemod error-code-migration --write . that you can run over your codebase to automatically change the error code. Both the flowconfig option and the codemod will be removed in the next version.Notable bug fixes:
Misc:
Likely to cause new Flow errors:
react-rule-hook-conditional error instead of react-rule-hook error.Notable bug fixes:
Likely to cause new Flow errors:
Likely to cause new Flow errors:
react-rule-hook-definitely-not-in-component-or-hook error, if the variable name doesn't conform to hook naming convention. exampleIDE:
Misc:
as casts with function generics and component generics!Likely to cause new Flow errors:
const foo = {baz: new Dog()};
type Foo = {bar?: string, baz: Animal};
declare function acceptFoo(foo: Foo): void;
acceptFoo(foo); // error
To fix the error, you can either annotate the object
const foo: Foo = {baz: new Dog()};
type Foo = {bar?: string, baz: Animal};
declare function acceptFoo(foo: Foo): void;
acceptFoo(foo);
or make the call site accepts readonly objects:
const foo = {baz: new Dog()};
type Foo = $ReadOnly<{bar?: string, baz: Animal}>;
declare function acceptFoo(foo: Foo): void;
acceptFoo(foo);
We provide a codemod to automate the annotation process. flow codemod annotate-literal-declaration --write --max-type-size 5. (You can adjust the max type size based on your needs).
IDE:
Library Definitions:
React$MixedElement is removed from builtin libdef. It will cause internal-type error since v0.258.0. You should use React.MixedElement instead.matchNew Features:
match feature using option experimental.pattern_matching=trueLikely to cause new Flow errors:
Library Definitions:
PropertyDescriptor type are marked as readonly. If you need a mutable version, you can introduce something like type MutablePropertyDescriptor<T> = {...$Exact<PropertyDescriptor<T>>, ...}Notable bug fixes:
Likely to cause new Flow errors:
nested-hook and nested-component lint errors which detect nested hook or component syntax within component or hook syntax. This is on by default.Notable bug fixes:
foo in import foo from './bar', but now we will count foo. If the pattern of import foo from './bar' happens a lot, then the autoimport algorithm will be more likely to suggest import foo from './bar' rather than import bar from './bar').react-rule-hook-conditional error for hooks called in a conditionally defined nested component.Notable bug fixes:
Notable bug fixes:
Likely to cause new Flow errors:
props param that's a subtype of interface {} will get react-rule-hook-definitely-not-in-component-or-hook error.react-rule-hook-mixed-with-non-hook error instead of react-rule-hook error. Calling functions named like hook but not in hook syntax will now get react-rule-hook-non-hook-syntax instead of react-rule-hook error.Notable bug fixes:
module.exports will correctly jump to the exporting fileParser:
''#!/usr/bin/env node\n'' when generating token listLibrary Definitions:
React.forwardRef is marked as deprecated. We might remove it from our builtin libdef in the future.Notable bug fixes:
export * will now be correctly indexed so that they won't be missing in autoimport results.Library Definitions
Float16Array typeLikely to cause new Flow errors:
React.Node will no longer be treated like components. Thus, all the hooks call in such functions will have react-rule-hook-definitely-not-in-component-or-hook errors.Object.assign will now trigger unsafe-object-assign lint error that's on by default. The type checking behavior for Object.assign will otherwise stay the same for now.react-rule-hook-definitely-not-in-component-or-hook.Parser:
It should have the same behavior as 0.269.0.
Likely to cause new Flow errors:
$Omit will trigger an internal-type error.Object.assign now has stricter behavior over maybe type and optional type inputs. exampleNew Features:
this is T as type-guard annotation on a method m, to refine x when calling if (x.m()) {}. This-type guards can only be used on declare classes and interfaces. (E.g. try-Flow)const type parameters that allow you to specify that an argument to a function is always treated as a const-expression, by annotating the type parameter with the const modifier. This eliminates the need to use the as const syntax when calling functions with this annotation. See more in our docs.Notable bug fixes:
module.system.node.root_relative_dirname will have correct import path instead of relative import path.@flowtyped will have correct import path instead of relative import path.Omit<...> to fail.Parser:
Breaking:
ubuntu-22.04. It might make Flow not runnable on older linux distributions.Likely to cause new Flow errors:
[react-rule-hook-conditional] instead of [react-rule-hook-naming-convention] errors.$Diff support is removed. If you have trouble migrating, you can try to polyfill it by this. However, $Diff has surprising behavior with regard to optional props in the second type parameter, which cannot be easily polyfilled (example).New Features:
react-rule-hook-naming-convention and react-rule-hook-conditional errors unsuppressable, you can add the following to the [options] section in flowconfig:unsuppressable_error_codes=react-rule-hook-naming-convention
unsuppressable_error_codes=react-rule-hook-conditional
Likely to cause new Flow errors:
We have updated the way type parameters are instantiated in generic calls, specifically when using upper bounds:
Support for $Rest is removed. Omit should be used instead. If you still have many instances of $Rest, you can replace them with $Diff as a temporary measure, but note that we intend to eventually remove $Diff as well.
React-rule hook errors related to conditional hook calls will now have react-rule-hook-conditional error code.
React-rule hook errors related to naming convention issues will now have react-rule-hook-naming-convention error code.
Notable bug fixes:
const x = 'a'; 'b' as typeof x as 'a'; (try-Flow) to type check without errors. With this fix, Flow will infer singleton literal types for primitive literals in contexts where such precision is required. Examples of this are: const-declarations (e.g. in const x = 42 will infer the type 42 for x), annotation positions (e.g. typeof x is equivalent to the type 42), conditionals (e.g. in if (x.tag === 42) {} Flow will infer the type 42 for the value 42, instead of number). In this part of the rollout, whenever this precision is not required Flow will infer the unsound type it used to infer before (a hybrid between the singleton and general type). Eliminating this unsound type completely will be done soon.flow-remove-types now handles the removal of empty imports after removing type/typeof imports (thanks @jbroma)libdef-override error to stick around after an incremental recheck.Likely to cause new Flow errors:
$PropertyType and $ElementType has been removed. Now referencing these types will just resolve to a global type if you have your own definition for them, and result in a cannot-resolve-name error otherwise. These types have been replaced by index access types for a long time. You can migrate to index access types by enabling use-indexed-access-type from https://www.npmjs.com/package/eslint-plugin-fb-flow and running the quickfixes. If you are unable to migrate, you can add the following to your global libdefs:type $PropertyType<T, K> = T[K];
type $ElementType<T, K> = T[K];
component()<: component(ref?: ref_prop), Flow will ensure that ref_prop is a subtype of void instead of a subtype of React.RefSetter<void>.React$ComponentType, which was previously given [internal-type] error on every usage, is now removed.React.ComponentType<Props> is now only an alias of component(...Props), instead of some special cased types. This comes with stricter checks and conversions, such as making Props readonly, erroring on the presence the ref prop instead of silently ignoring them, and ensures that Props is a subtype of {...}. In addition, the React$AbstractComponent type is removed.Notable bug fixes:
Library Definitions:
React.lazy and React.memo is now generic over the presence or absence of ref prop.@flowtyped resolution support work on Windows.Notable bug fixes:
libdef-override errors.libdef-override errors not being raised even if it's turned on.Notable bug fixes:
libdef-override=off in [lints] section actually turn off all libdef-override errors.Likely to cause new Flow errors:
[libdef-override]. The error cannot be suppressed without specific error code like $FlowFixMe[libdef-override]. It can be turned off by turning off the libdef-override lint.New Features:
Number static methods Number.isFinite, Number.isInteger, Number.isNaN, and Number.isSafeInteger now apply a refinement that their input is a number. Note that the top level isNaN and isFinite functions (not off of Number) do not apply the same refinement as they first coerce their input to number.Notable bug fixes:
Misc:
Likely to cause new Flow errors:
New Features:
declare namespace is now supported in toplevel library definitions.Notable bug fixes:
Library Definitions:
flow-typed.config.json in the root of your project with the following content:{
"env": ["node", "dom", "bom", "intl", "cssom", "indexeddb", "serviceworkers", "webassembly", "jsx"]
}
Likely to cause new Flow errors:
React$Component directly will now be an error.React$ComponentType, React$Context and React$RefSetter will now trigger internal-type errors.New Features:
divNotable bug fixes:
ClientRect and ClientRectList with aliases to DOMRect and DOMRectList
This fixes the type definitions for the DOM APIs in Flow, but replacing an nonexistent globals ClientRect and ClientRectList types with just an alias to DOMRect and DOMRectList.React.ComponentType<{}> to be a subtype of component()IDE:
Library Definitions:
flow-typed.config.json in the root of your project with the following content:{
"env": ["node", "dom", "bom", "intl", "cssom", "indexeddb", "serviceworkers", "webassembly"]
}
Notable bug fixes:
Notable bug fixes:
react module is provided as a userland module.New Features:
`${1n}`. Addition with string (e.g. 1n + 'blah') is still banned.["a", null].filter(s => s != null) it will automatically infer that the arrow function encodes a x is string type guard and will apply it on the input array resulting in aArray<string>. (try-Flow)module.system.node.root_relative_dirname will allow conditional mapping like module.system.node.root_relative_dirname='<PROJECT_ROOT>/foo' -> 'bar'. Under such config, import 'a' will only be resolved to <PROJECT_ROOT>/bar/a if import 'a' is in a file in the <PROJECT_ROOT>/foo directory. This feature will be helpful if you want to combine two flow roots with different module.system.node.root_relative_dirname config.Likely to cause new Flow errors:
Notable bug fixes:
true or false. (e.g. try-Flow)Parser:
declare global {...} (using it will still result in an error). The AST will have the shape of{
"type":"DeclareNamespace",
"loc": ...,
"range": ...,
"global":true,
"id":{
"type":"Identifier",
"loc": ...,
"range":...,
"name":"global",
"typeAnnotation":null,
"optional":false
},
"body":{
"type":"BlockStatement",
...
},
}
Library Definitions:
React$PureComponent is removed. If you want to refer to it, it needs to be imported from react.New Features:
number typed keys (rather than just number literals) to create objects, these will be treated as dictionaries {[number]: T}Notable bug fixes:
IDE:
Library Definitions:
React$FragmentType is removed from Flow's builtin global type definitions.Notable bug fixes:
Likely to cause new Flow errors:
Notable bug fixes:
IDE:
bar in export {foo as bar} from '...', we will always jump to itselffoo in export {foo} from '...' or export {foo as bar} from '...', we will always jump to the name at the export, if this statement is well typed.foo in export {foo} from '...' or export {foo as bar} from '...', we will jump to itself if the statement is not well-typed.require('...') expression will now jump to the default export of an ESM module if available, or the first export of an ESM module.Library Definitions:
React.Context has been updated to support React 19's context as provider model. Given this change, you might need additional annotations on exports. e.g.IDE:
Likely to cause new Flow errors:
react.ref_as_prop=disabled is removed.React$Node and React$MixedElement outside of libdefs will now trigger internal-type errors.Library Definitions:
Array.concat().Misc:
"source". It can help to prevent VSCode sending flow irrelevant code actions to handle during save.Likely to cause new Flow errors:
export const obj = {f: "foo"}; was {f: str<"foo">}, where str<"foo"> was a type that opportunistically and unsoundly behaved either as string or as the singleton type "foo".{f: string} for obj.export const x = "foo"; Flow will export the type "foo".as const modifier.string or any keys. Now, if the computed property is added to some existing objects (e.g. {foo: string, [stringTypedKey]: v}), then we will error on the property. Otherwise, the {[key]: value} will be {[typeof key}: typeof value}[react-rule-unsafe-mutation] errors are raised.(?string) extends string ? true : false is evaluated to true | false instead of false). This is now fixed, and code that depends on the bug might have new errors.typeof x === 'function', and then do typeof x === 'object', the result is now empty as that is impossible.React.Config type, deprecated in v0.254, is now removed.New Features:
'key' in x now refines the type of x to objects which have the property key.
in checks for both own and non-own properties..length instead), and also because Flow doesn't handle array holes.no_unchecked_indexed_access=true in flowconfig, which is equivalent to noUncheckedIndexedAccess from TS. It will add | void to every indexed access with general string key on dictionary objects or number key on arrays.react.ref_as_prop=partial_support, and this is now the default. (To disable it, use react.ref_as_prop=disabled.) Under this mode, ref prop in jsx will be treated as a regular prop for function components, but utility types like React.ElementConfig<...> still won't include the regular ref prop yet.Notable bug fixes:
Library Definitions:
getNotifications and showNotification API for ServiceWorkerRegistrationNotable bug fixes:
super in an object method. Such cases are now user-facing errors.Likely to cause new Flow errors:
React$RendersExactly<typeof Component> type instead of React$Element<typeof Component> type. All existing usages intended to create an exact react element will now error as a result. Using it as type passed to render type, React.PropsOf, React.PropOf and React.RefOf is unaffected and will not be affected in the future. If you want exact react elements, the only way that doesn't trigger Flow error is by ExactReactElement_DEPRECATED<typeof Component>.Library Definitions:
React.Config type is marked as deprecated and will be removed soon. You can create your own equivalent type withtype ReactConfigShim<Props, DefaultProps> = $ReadOnly<{
...Omit<Props, $Keys<DefaultProps>>, ...Partial<DefaultProps>
}>;
Misc:
Notable bug fixes:
Likely to cause new Flow errors:
Library Definitions:
toSpliced method type (thanks @aph!)Likely to cause new Flow errors:
React$ElementRef is now implemented with a conditional type instead of a builtin Flow utility type. You might see new errors with generic React$ElementRef. Most of the times, you should replace React.ElementRef<T> with just T if there are no other uses of generic T.New Features:
@flowtyped like directories via module.declaration_dirnames config. e.g.module.declaration_dirnames=<PROJECT_ROOT>/decl1
module.declaration_dirnames=<PROJECT_ROOT>/decl2
Please note that when you set this, @flowtyped at the root will no longer be considered special, and you will need to explicitly add it like
module.declaration_dirnames=<PROJECT_ROOT>/@flowtyped
Notable bug fixes:
empty.IDE:
includeDeclaration from LSP request for find-references command. In practice, this means that "find all references" in vscode will continue to return both declaration and all uses, while "go to references" will exclude the declaration.Likely to cause new Flow errors:
$ReadOnly applied, which might cause new errors.New Features:
Notable bug fixes:
[declarations] section will have all lint errors silenced.Misc:
Likely to cause new Flow errors:
React.AbstractComponent type. We recommend replacing them with component types. Since v0.249.0, we have provided a codemod via the flow-upgrade package to aid larger codebases with this conversion: yarn run flow-codemod eliminateAbstractComponent path/to/src.React.AbstractComponent type, we also removed support for the internal React$AbstractComponent when more than 1 type argument has been passed. Similarly, you should migrate to use component types if you want to specify ref props and renders.New Features:
@flowtyped directory at the root, they can be resolved by the relative path without leading ./ relative to @flowtyped. e.g. <PROJECT_ROOT>/@flowtyped/react.js.flow can be used to type the react package, and <PROJECT_ROOT>/@flowtyped/react/jsx-runtime.js.flow can be used to type react/jsx-runtime module. We now recommend using this approach instead of using declare module in global libdef.Notable bug fixes:
any will now correctly propagate to inferred render type. example.Library Definitions:
React.AbstractComponent. Most of the code won't be affected, but you might have to sometimes make the Props readonly.Likely to cause new Flow errors:
Notable bug fixes:
all option is specified in the config of flow-remove-types, we now respect it and will correctly handle Flow-typed files without @flow pragma.Likely to cause new Flow errors:
React$AbstractComponent outside library definitions will now trigger internal-type lint error, which is on by default. React.AbstractComponent is also marked as deprecated. We recommend replacing them with component types. We have provided a codemod via the flow-upgrade package to aid larger codebases with this conversion: yarn run flow-codemod eliminateAbstractComponent path/to/src.Notable bug fixes:
StringPrefix and StringSuffix when used as a component syntax prop.as cast support in flow-remove-types.Library Definitions:
React.cloneElement. e.g. React.cloneElement(e, {ref: 'foo'}) will be an error.React$Ref type and various aliases of it are removed.IDE:
React.Component annotated exported will now also show up in auto-imports in a type position.Breaking changes:
%checks) is removed. It will still parse, but all of them will error with unsupported-syntax, and %checks will be completely ignored for type checking purpose as if it doesn't exist.$TupleMap support is now removed. $TupleMap will now resolve to the global definition is there is one, or it will fail and the type becomes any.Likely to cause new Flow errors:
$TEMPORARY$* types is dropped. If your codebase happens to have any of these types, you can replace them with there sound and well-documented equivalents:
$TEMPORARY$object<{props}> with $ReadOnly<{props}> or {props}$TEMPORARY$array<T> with $ReadOnlyArray<T> or Array<T>$TEMPORARY$number<42> with number or '42'$TEMPORARY$string<"foo"> with string or "foo"flow-upgrade package to aid larger codebases with this conversion: yarn run flow-codemod replaceTemporaryTypes path/to/src.Object.freeze({ A: 'a', B: 'b' }) is now {+A:'a',+B:'b'} both locally within a file and when the object is being exported. This replaces an earlier unsound behavior where the type of A would opportunistically behaved either as string or 'a' depending on the context where it appeared.contextTypes and childContextTypes in react class components are now empty typed, so declaring legacy context in React will be an error.React.RefSetter<...> type.Parser:
type Foo = (component(x: number) renders Bar);IDE:
renders React.Node on hover.: renders <annot> at the position that expects a render declaration, the quickfix will suggest removing : instead of replacing : with renders.Library Definitions:
util.stripVTControlCharacters for NodeJS.Misc:
Breaking changes:
$Call type is removed. $Call will now resolve to whatever $Call points to in the global libdef. If you need more time to migrate, you can create a shim like $Call<F, T> = $TupleMap<[T], F>[0], but please note that we intend to remove support for $TupleMap eventually.deprecated-type-dollar-call lint is removed, since the support for $Call is removed.react.disable_function_components_default_props config option is removed. It is on by default since v0.238.Likely to cause new Flow errors:
$TupleMap is deprecated and will be soon removed, now that mapped type works on array inputs. Existing $TupleMap will still work in this release, but every use will trigger a deprecated-type lint that is on by default.type A = React$ElementConfig<hook (props: {foo: string}) => void>; will now error.New Features:
Notable bug fixes:
flow-remove-types now correctly handles as cast with generics.IDE:
React.AbstractComponent type will be shown in the component type syntaxLibrary Definitions:
Likely to cause new Flow errors:
$ObjMap will resolve to a user-defined $ObjMap global if it's available in your libdef. You can use type $ObjMap<O, F> = {[K in keyof O]: $Call<F, O[K]>} to get most of the same behavior, except that in the mapped type version O[K] will include void for optional props. Please note that this should be considered as a permanent shim, because we intend to eventually remove $Call.flow codemod key-mirror command was removed, since this codemod tries to convert $ObjMap to $KeyMirrordeprecated-type-objmap lint was removed.void as the instance, so React.ElementRef<component> of such component will return void.New Features:
{[K in keyof <array or tuple type>: <mapped type>}.
Notable bug fixes:
IDE:
Library Definitions:
React.Ref is marked as deprecated. Use React.RefSetter instead for ref props, and React.RefObject for returns of useRef.React.RefSetter now includes null and void.Promise.all and Promise.allSettled have been updated to use mapped type instead of $TupleMap. The requirement on the type arguments are slightly changed.Misc:
Website:
IDE:
textDocument/prepareName LSP request. This ensures that Flow's rename support can be surfaced when multiple VSCode extension adds rename support for JS files.Likely to cause new Flow errors:
React.Element type, deprecated in 0.243.0, is now removed.New Features:
{ of a JSX attribute value.react.custom_jsx_typing=true. Under this flag, Flow will type check jsx by through your self-defined global type React$CustomJSXFactory type, which should be a function type that accepts arguments according to jsx spec. e.g. You can write a loose one like type React$CustomJSXFactory = (component: any, props: any, ...children: any) => React.MixedElementNotable bug fixes:
globalThis.React.Node being incorrectly unavailable.IDE:
<A /> where A is in component syntax) will no longer be shown in hover with shorthand syntax like A. Instead, it will be shown as React$Element<typeof A>Likely to cause new Flow errors:
inexact_tuple_types_syntax option (which was on by default) is now deleted. Make sure you are using hermes-parser and related packages at version >= 0.23.0renders React.Element<React.AbstractComponent<{}, mixed, renders* A>>. Invalid render types will behave like any.React.Fragment.renders* T where T is generic is now banned.Notable bug fixes:
Likely to cause new Flow errors:
deprecated-type and untyped-type-import lint are on and at error level by default.React$ElementConfig vs React.ElementConfig) are now a lint error that's enabled by default. To disable it, set internal-type=off in the lints section of the flowconfig. For now, these types are still allowed in libdef files, but we plan to also disallow it in the future. To codemod existing code, get the latest flow-upgrade package and run yarn run flow-codemod replaceReactDollarUtilityTypesReact$Element type is banned via the internal-type lint. The React.Element alias still exists for now, but it is marked with @deprecated in the jsdoc. Please read the jsdoc for better alternatives. A global alias ExactReactElement_DEPRECATED is added to help you clearly mark the use of exact React element types, and you should use it to replace React.Element that you cannot replace without compromising runtime type safety.New Features:
declare component statement and component type is enabled by default.Notable bug fixes:
Misc:
experimental.namespaces config option is removed. Namespaces support is enabled by default in the previous release.Library Definitions:
.replaceChildren method type definition for dom nodes.Object.getPrototypeof is still special cased, but the special-casing is only available for a syntactic Object.getPrototypeof(...) call. If you try to use Object.getPrototypeof in some other ways (e.g. const f = Object.getPrototypeof; f(...)), you will get a a less precise and accurate typing for it. The Object$GetPrototypeOf type, which was used to back the special case behavior, is removed.New Features:
Pick utility type with string literals in the second type argument, go-to-definition on the string literal will jump to corresponding prop's locationNotable bug fixes:
Likely to cause new Flow errors:
$Flow$DebugPrint was removed. To see the internal representation of type, use the flow type-at-pos command with flag --debug-print-internal-repr. Note that this is for debugging purpose only, and you should never depend on the output of --debug-print-internal-repr== and !=.invalid-render errors can no longer be suppressed without specific error code.$Exact<...> is involved. Some invalid $Exact<...> type will now have not-an-object error code.New Features:
declare namespace support is enabled by default.StringSuffix type, which goes along with the recently added StringPrefix type. StringSuffix can be used to type strings with a specified suffix. E.g. StringSuffix<'!'> allows for 'yay!' and 'woo!'. The type argument for the suffix must be a string literal. The second, optional, type argument can be used for the type of the remainder of the string after the suffix is removed.Notable bug fixes:
IDE:
my-package or my-package/foo instead of a relative path import.Library Definitions:
Reflect.setPrototypeof are no longer special-cased, and the backing special type Object$SetPrototypeOf is removed. The new typing is intentionally loose. Similar to Object.setPrototypeof, this is inherently unsafe since Flow won't track prototype mutations.Object.assign is still special cased, but the special-casing is only available for a syntactic Object.assign(...) call. If you try to use Object.assign in some other ways (e.g. const f = Object.assign; f(...)), you will get a a less precise and accurate typing for it. If you don't like the default fallback type, you can override the Object$Assign type. While the special-casing behavior will stay for the syntactic call, you should migrate your code to use the spread syntax instead.No changes from 0.240.0
Likely to cause new Flow errors:
obj.type === 'foo'. exampleFunction.prototype.apply and Function.prototype.call are now typed using userland types instead of hardcoded builtin support. You might see slight inference differences, error message and code changing as a result..constructor property of object types. (D58538540 pvekris)void, not empty.New Features:
StringPrefix utility type. This is the type of the remainder of the string after the prefix is removed. For example, "$1", "$2" are subtypes of StringPrefix<'$', '1' | '2'>, but "$999" is not. StringPrefix<X> is equivalent to StringPrefix<X, string>$Values utility type to get the type of the elements of an array type or tuple type....args as a union of tuples). [example]Notable bug fixes:
Library Definitions:
String.codePointAt now returns number | voidNotable bug fixes:
files.implicitly_include_root=false config.Likely to cause new Flow errors:
Array.push, Set.add, Map.set, etc). These values are expected to be read-only, and we previously errored on directly setting their props; this release extends this enforcement to method calls as well.implies before the type guard (example try-Flow)New Features:
StringPrefix type represents strings which being with the specified prefix. E.g. StringPrefix<'data-'> allows for 'data-floo' and 'data-bar'. The type argument for this type must be a string literal. [example]globalThis.Notable bug fixes:
new C() will jump to definition of C instead of the constructor definition. Hovering on C will still show the jsdoc on the constructor.as const casts and as casts in flow-remove-typesIDE:
Library Definitions:
shift() and pop() on an Array<T> will now return T | undefined.cause property on Error instance; Support error cause in error constructor optionsFinalizationRegistryCSSSupportsRulecloseAllConnections, closeIdleConnections to https$ServerMisc:
Notable bug fixes:
flow force-recheck doesn't respect files.implicitly_include_root=false config.This release is used to test the release automation powered by GitHub Actions. No changes are expected.
Likely to cause new Flow errors:
react.disable_function_components_default_props that will make Flow ignore defaultProps on function components for React component typing purposes. This flag is now on by default. If this is too disruptive for your codebase, you can turn this off for now. Note that we do not intend to keep this flag forever, so you should try to turn this flag on as soon as possible.React.createElement have an opaque type, which means calling this function directly will be an error. This will be helpful to prepare for React 19 changes. Note that JSX typing is unaffected. If you are not ready for this change, you can override your library definition like this to approximate the previous behavior as much as possible.invalid-component-prop error, Flow will no longer make the entire props to be any type. Instead, Flow will create a Props type as if these invalid props do not exist. exampleObject.freeze({ A: "a", B: "b" }) as {+A: "a", +B: "b"}, ie we use readonly properties and singleton types for literal initializers. Casts like this example will now be an error.untyped-import errors are now on the import source rather than imported names.New Features:
files.implicitly_include_root=false (default is true, which is the current behavior), Flow will no longer include everything under the directory where the flowconfig is in by default.Notable bug fixes:
Array.reduce and returning a union type (e.g. try-Flow)[...[]] as [] now works.nested-component errors can now be suppressed.IDE:
({ foo: { | } } as ?{ foo: { x: number }}) it will populate x, when calling autocomplete at the point of the cursor |. (try-Flow)React type-only namespace.<Foo.Bar />.export {Foo} from 'bar' statements will now appear in autoimport results.autoimports_ranked_by_usage is now enabled by default.new C(e)Library Definitions:
useOptimistic and useActionState API definitionsTextDecoderStreamNew Features:
react.disable_function_components_default_props=true, Flow will ignore defaultProps on function components for React typing purposes. Note that we do not intend to keep this flag forever, so you should try to turn this flag on as soon as possible.Notable bug fixes:
Likely to cause new Flow errors:
New Features:
jest_integration=true, Flow will now error on some jest mocking APIs (e.g. jest.mock('./my-module')) if the module doesn't exist.Notable bug fixes:
[...[]] as [] now works.React.ElementConfig/Props when passed in a component syntax component (e.g. try-Flow)Likely to cause new Flow errors:
super with a props object. exampleReact.cloneElement. You might see errors being shifted around, and some advanced patterns no longer supported. The API is not encouraged by React, so migrating away from it is recommended.react.runtime=classic, we now type check the JSX unconditionally using the right React.createElement typing, and check whether the locally defined React has the right React.createElement definition. If you have some JSX that's already invalid, you might see different errors. exampleReact$CreateClass type, aliased to any since v0.176, is removed.isValid Flow Enums method, reverting back to behavior from before v0.232.$CharSet, an undocumented feature, has been removed. RegExp$flags, which depends on $CharSet, is also removed. In most cases, you should replace these types with string.--traces and the corresponding flowconfig option has been removed.React.createFactory libdef is removed. This API is already deprecated and will be removed in React 19.Notable bug fixes:
mixed (such as $NonMaybeType<mixed>). (try-Flow examples)Misc:
export type * (ExportAllDeclaration) nodes with flow-remove-types (thanks @jbroma!)Parser:
bigint property to match ESTree spec. Numeric separators are removed (_), and should contain only decimal digits.IDE:
component_syntax=true, autocomplete will provide component and hook keyword in appropriate places.Library Definitions:
$asyncIterator, which is never a real global, is removed from global libdef.$await in the libdef. If you are depending on it like typeof $await, you can replace it with <T>(Promise<T> | T) => T.Misc:
flow ast will now parse component syntax rather than reject it. You can pass --no-component-syntax to get the old behavior (D56501290 samzhou19815)Likely to cause new Flow errors:
ref.current within nested functions of hooks and components that are called during rendering.obj[key] where obj is not a dictionary object and key is a string used to not error and just silently return any. We now error on this pattern.Likely to cause new Flow errors:
type T = T or type Foo = typeof foo; const foo: Foo = .... In addition to this, you might see some errors being moved around.any.New Features:
EnumValue<>, which represents all Flow Enum values. You can constrain the enum values to those with a particular representation type by supplying the type argument, e.g. EnumValue<string>.Enum<>, which represents all Flow Enums (this is a complement to the new EnumValue type). You can constrain the enums to ones which have a particular enum value, e.g. Enum<> is the same as Enum<EnumValue<>>, and the type of all enums with string representation types is Enum<EnumValue<string>>. These "abstract enums" have no know members, so you can't access members or exhaustively check them, but you can use methods such as .members(), .cast(), etc.=== comparison of abstract Flow Enums as well as Enums themselves with the same ID..valueOf(), e.g. enum E {A, B}; const s: string = E.A.valueOf().Notable bug fixes:
Enum and EnumValue to $NotNullOrVoid - previously there was no supertype for all enum values or enums.IDE:
Likely to cause new Flow errors:
Notable bug fixes:
of bigint during parsing. We were previously not correctly inferring that this was a bigint enum.Parser:
ReadOnlyTypeAnnotation in parser output for annotations like readonly string[]. Now we output it as TypeOperator with "operator": "readonly"IDE:
as or as const has low precedenceLibrary Definitions:
Likely to cause new Flow errors:
$Compose and $ComposeReverse types are removed. We recommend to use overloads to approximate their behavior instead. e.g.declare export function compose(): <T>(a: T) => T;
declare export function compose<F: (...$ReadOnlyArray<empty>) => mixed>(
f: F,
): F;
declare export function compose<A, T: $ReadOnlyArray<any>, R>(
f1: (a: A) => R,
f2: (...T) => A,
): (...T) => R;
declare export function compose<A, B, T: $ReadOnlyArray<any>, R>(
f1: (b: B) => R,
f2: (a: A) => B,
f3: (...T) => A,
): (...T) => R;
declare export function compose<A, B, C, T: $ReadOnlyArray<any>, R>(
f1: (c: C) => R,
f2: (b: B) => C,
f3: (a: A) => B,
f4: (...T) => A,
): (...T) => R;
declare export function compose<R>(
f1: (b: any) => R,
...funcs: $ReadOnlyArray<(...$ReadOnlyArray<empty>) => mixed>
): (...$ReadOnlyArray<any>) => R;
declare export function compose<R>(
...funcs: $ReadOnlyArray<(...$ReadOnlyArray<empty>) => mixed>
): (...$ReadOnlyArray<any>) => R;
New Features:
isValid Flow Enums method to use a type guard, allowing it to refine its input to the enum type in a conditional context.
E.g.enum Status {Active, Off}
const s = "Active";
if (Status.isValid(s)) {
s as Status; // Should work
}
export type Foo = ... and export interface Bar {...} statements are now allowed in declare module and declare namespace bodies.flow codemod remove-unnecessary-react-import which can help remove unnecessary react imports under react.runtime=automaticNotable bug fixes:
as or as const has low precedenceLibrary Definitions:
Likely to cause new Flow errors:
New Features:
method-unbinding errors with indexed access types.relay_integration.esmodules option. When this option, along with relay_integration, is enabled, Flow will treat graphql fragments/queries/etc. as import default rather than require. Use this when you output ESM from Relay's codegen (e.g. eagerEsModules).Notable bug fixes:
AsyncGenerator<T, void, void> type is expected (e.g. try-Flow)IDE:
AUTO332 appeared in the result of string literal type completion.Library Definitions:
FileSystem APIs (thanks @ZelJin).StorageManager class (thanks @ZelJin).checkPropTypes, DOM, createClass, ConcurrentMode from react module.import React from 'react', they can also be used without imports, e.g. type N = React.Node.Likely to cause new Flow errors:
// a.js
export type Foo = string;
// b.js
const A = require('./a');
module.exports = {...A};
// c.js
// previously allowed, no longer allowed
import type {Foo} from './b';
// a.js
// we incorrectly resolve x to refer to
// be external to the function params,
// which is a global in this case
export function foo(x: string, y: typeof x) {}
// b.js
import {foo} from './a';
foo("", 3); // no error before, errors now
Array = 3; $ReadOnlyArray = 2; Now the latter is banned.value-as-type or recursive-definition errors will no longer affect which branch to take in overload resolution.New Features:
type T = typeof foo<string>. This syntax is supported in prettier since v3.1. If you previously enabled the flag typeof_with_type_arguments=true, you need to remove it.<Foo<string, _, number >propA='d' />. Note that some type arguments can be inferred using the _ syntax.NoInfer intrinsic that will be available in TypeScript 5.4.experimental.ts_syntax=true, Flow will
$ReadOnly<[...]> and $ReadOnlyArray<...> without error.$Keys without error. Note that there are behavior differences between $Keys<> and keyof right now (flow, TS), so use it with caution.unknown never and undefined into Flow equivalent mixed empty and void without error.readonly in out, in out without error.Misc:
experimental.ts_syntax is now always on in https://flow.org/try.Misc:
experimental.blocking_worker_communication=false.Misc:
Likely to cause new Flow errors:
invalid-recursive-exported-annotation will now have error code of recursive-definition.value-as-type errors. (example).declare module will no longer cause parse errors. Instead, they will be errored on during type checking.declare export type and declare export interface statements in toplevel are no longer parser errors. Instead, they will now be errored during type checking.toplevel-library-import errors and unsupported-statement-in-lib errors will all have unsupported-syntax error code now.New Features:
experimental.ts_syntax flag that you can set to true. When this flag is on, Flow will no longer complain about certain TypeScript syntax, and will automatically turn them into the closest Flow equivalent types. Initially, we support the following: Readonly, ReadonlyArray, ReadonlyMap, ReadonlySet, NonNullable, and using extends to specify type parameter bounds. In the future, more kinds of types that we currently parse but error on might be added. (e.g. keyof). Please note that the support here is best effort. We make no guarantee that these types have the same semantics as those in TypeScript 100% of the time, but for common cases, it might be good enough for you.Notable bug fixes:
declare module, all the values will be auto-exported if we cannot decide whether the module is in CJS or ESM. However, support for declare const and declare let was missing. This has now been fixed.Misc:
both the default value for the .flowconfig casting_syntax option, if not supplied.Likely to cause new Flow errors:
React.cloneElement with polymorphic components. Eg. try-Flow. Note that React.cloneElement is deprecateddeclare module is no longer a parser error, but a type checking errordeclare module is now explicitly banned in nested scope and outside of library definition files. It already does nothing under those contexts.New Features:
prop = (foo: string): number => 3.Notable bug fixes:
flow check to always return 0 errors, when some parts of temporary directory is a symlink.React$Element. (e.g. try-Flow)export function f(a) {}, we now say "Missing type annotation at identifier" instead of "Missing type annotation at array pattern".Parser:
declare namespace Foo {...} statements. The body of the declare namespace statement shares the same restrictions of declare module.declare module are no longer parse errors. They are now type checker errors.Likely to cause new Flow errors:
type T = T as empty, instead of any. (e.g. try-Flow)..call() on polymorphic functions where the return type is under-constrained (e.g. try-Flow). To fix add an annotation to the return result.Parser:
Library Definitions:
Array.from overloads. It might cause some error locations and codes to change.window.navigator.storage (thanks @ZelJin).Likely to cause new Flow errors:
IDE:
Notable bug fixes:
DOMStringList as iterable, so that it works with Array.from(...) (thanks @bobrovnikov)Notable bug fixes:
Notable bug fixes:
Likely to cause new Flow errors:
%checks is now deprecated. It will still work as before (for now), but if you enable the deprecated-type Flow lint, you will see additional errors. Instead, use type guards.$Call, $ObjMap, $ObjMapi, $ObjMapConst are now deprecated. They will still work as before (for now), but if you enable the deprecated-type Flow lint, you will see additional errors. Since Flow 0.209, you can now use builtin types like Parameters, ReturnType, Pick, Omit to easily extract and transform types. For more advanced use cases, you can read the docs of conditional type and mapped type to understand how to write it in equivalent ways.number keysnumber keysNew Features:
const obj = {1: true, 2: false}Notable bug fixes:
Array.from with string input and also mapping function, e.g. Array.from('str', x => x.length)IDE:
Library Definitions:
crypto object, crypto.getRandomValues, and crypto.randomUUIDStatelessFunctionalComponent type from the 'react' module and the React$StatelessFunctionalComponent type. The name might give an incorrect assumption that Flow can actually check that a function component doesn't use stateful hooks or can be called directly. If you have code that still uses this type, we recommend you use the React.AbstractComponent type, since it forces you to not make any assumption of what kind of React component you are dealing with.Before Flow 0.223, the autoimport system uses the filename as a hint of the name for default export. e.g. if the filename is foo.react.js or foo.js, regardless of whether the default export in that file has a name or not, or even the default name is bar, autoimport will always import it as import foo from 'foo'.
However, in the new system starting from Flow 0.223, we will use the name of the default export as a stronger hint. In a lot of files that just give a default export a random generic name, they are relying on the old system to get reasonable auto imports.
It's not practical to update every Flow codebase to avoid the UX regression, so now auto-import will provide both options.
Notable bug fixes:
Notable bug fixes:
Improved precision of server states, that are visible either in vscode status bar, or through the flow status command.
Notable bug fixes:
any. (Example: Issue #9107)IDE:
Misc:
incremental_error_collation flowconfig option is not recognized anymore.Library Definitions:
status global from dom.jsReact module. You should always import react with lowercase like require('react') or import React from 'react'New Features:
Notable bug fixes:
declare export statements in hover and autocomplete. This means that jsdoc for exports in declare module will finally show up in IDE services.Library Definitions:
USBConnectionEventSecurityPolicyViolationEventcrypto.randomUUID, http$Server.closeAllConnections, http$Server.closeIdleConnectionsLikely to cause new Flow errors:
React.Fragment to only accept children and the key prop.React.useRef to return an opaque type.any without error.Notable bug fixes:
Performance:
Library Definitions:
IntersectionObserver types.IndexedDB transaction now allows consuming storeNames as DOMStringList.options to IndexedDB transaction.durability to IDBTransaction.Notable bug fixes:
Likely to cause new Flow errors:
| voidNotable bug fixes:
Misc:
Misc:
Misc:
Misc:
Misc:
Likely to cause new Flow errors:
React.Element to be an inexact empty object, effectively making it opaque.
React doesn't recommend inspecting children and React.Element, so we make the change to increase friction. See https://react.dev/reference/react/Children#alternatives for alternatives.
To keep existing code type safe, you can add a function like the following to explicitly expose the internal of React.Element:export default function DangerouslyAccessReactElementInternals_DO_NOT_USE_IN_NEW_CODE<
E: React$ElementType,
P,
>(e: React$Element<E, P>): {
+key: React$Key | null,
+props: P,
+ref: any,
+type: C,
} {
return e;
}
A in A extends B ? C : D is a generic type. This is a behavior change that might cause new errors (example). Previously, we distribute over unions in more cases, which contradicts what we said in the docs, and caused some weird behavior that's fixed in this version.propTypes, Flow will now emit signature-verification-failure.New Features:
casting_syntax option which can be colon (current), as, or both. If setting is both, both (x: T) and x as T are allowed. If set to colon or as, only (x: T) and x as T are allowed respectively.Notable bug fixes:
Misc:
React.Element types. Instead, it will insert general types like React.MixedElement.Library Definitions:
CanvasRenderingContext2D.roundRect.tagName to DOM element declarations (thanks @aselbie).New Features:
--incremental-error-collation.)Likely to cause new Flow errors:
$ReadOnly, which is previously completely unchecked. It also results in Flow complaining about some incorrect bounds. exampleNew Features:
Notable bug fixes:
obj[m](arg).Misc:
Library Definitions:
Array.prototype.findLastIndex(), String.prototype.at(), TypedArray.prototype.at() and Object.hasOwn() (thanks @pascalduez).URL definitions (thanks @pascalduez).This is same as 0.217.1, but we have some issue publishing 0.217.1 to npm, so we will publish this new version instead.
Notable bug fixes:
experimental.global_find_ref=true/experimental.global_rename=true) is ongoing, all other IDE services will be blocked. We fixed it so that other IDE requests can still be served.Likely to cause new Flow errors:
React.Element is now opaque, but we still expose some of its internal structure via the bound on the opaque type. You should not depend on the internal structure. In a future release, we plan to make React.Element truly opaque.forwardRef and useImperativeHandle to be write-only. Patterns that rely on refining these params to an object and reading the ref field are misusing these APIs. exampleReact.ElementProps is now more precise when applied to AbstractComponents, resulting in the config type of the component rather than mixed. This will cause errors when elements of components with different props are passed into React.Element<> types.Parser:
typeof annotations. e.g. typeof MyGenericClass<string, number>. Type checking for this syntax is still not supported.Library Definitions:
URLSearchParams definitions (thanks @pascalduez).AbortSignal definitions (thanks @pascalduez).Array copying methods (toReversed, toSorted, toSpliced and with) the $ReadOnlyArray class definitions (thanks @pascalduez).Notable bug fixes:
Likely to cause new Flow errors:
module.system.haste.use_name_reducers=false is removed. For now this option defaults to true and can only be set to true. The option to set the only possible value will be removed in a future release.Notable bug fixes:
Library Definitions:
USB web API definitions.Notable bug fixes:
Likely to cause new Flow errors:
New features:
IDE:
Library Definitions:
Likely to cause new Flow errors:
$Call, $ObjMap, $ObjMapi, $ObjMapConst, $TupleMap. Previously hidden type errors might be revealed now.tuple_enhancements, conditional_type, mapped_type, type_guards in flowconfig, since these options have been removed. They were enabled by default since v0.212.0.IDE:
Notable bug fixes:
React$AbstractComponent to match the React.AbstractComponent type alias in our libdefs. [try-flow]Library Definitions:
parseArgs to the Node.js util module library definitionNotable bug fixes:
Likely to cause new Flow errors:
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:
Parser:
as/satisfies casts in a row.Library Definitions:
Intl.Locale classLikely to cause new Flow errors:
$NonMaybeType, and $ReadOnly. You might see new errors revealed as a result.$Pred and $Refine have been deleted. These are replaced by type guards.New Features:
Pick and Omit to work on interfaces and instances.Notable bug fixes:
IDE:
require, go-to-definition will now jump to the location of the original definition's name.Notable bug fixes:
Likely to cause new Flow errors:
Notable bug fixes:
Parser:
Library Definitions:
Omit type implementation. Now it will preserve the optionality and the variance of the input object. exampleNotable bug fixes:
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:
Likely to cause new Flow errors:
New Features:
Notable bug fixes:
void would appear in autocomplete suggestions more than onceMisc:
Parser:
Library Definitions:
replace and replaceSyncarrayBuffers to Node libdefs for process.memoryUsage()'s return typeMisc:
Likely to cause new Flow errors:
React$PropType$Primitive are deleted. React has deprecated PropTypes since v15.5.const x: typeof x = ...). An exception is when the name of the variable appears under an object type constructor. For example, the annotation const o: { f: typeof o } = ... is allowed.Notable bug fixes:
Library Definitions:
e.g. [1, [1,2]].flat() will now correctly have inferred type of Array<number>.Notable bug fixes:
Likely to cause new Flow errors:
IDE:
Notable bug fixes:
function f(x: number, y: typeof x) {})Misc:
Library Definitions:
Likely to cause new Flow errors:
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:
div to JSX autocompleteexperimental.mapped_type=true to try them.Notable bug fixes:
@noflow files in "all" modeexport statementsLibrary Definitions:
rel as an attribute to HTMLFormElementWeakRef class definitionariaHidden DOM propertyLikely 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, use Partial instead. Read this blog post for more.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:
string supertypes to be used as keys in a dictionary, and have that opaque type be preserved when using Object.keys.Readonly, ReadonlyArray, ReadonlyMap, ReadonlySet, NonNullable.Notable bug fixes:
[invalid-computed-prop] errors. try-Flow.Partial/Required caused errors to be positioned poorly.Misc:
mixed instead of a generic type if that generic type has a default bound of mixed. try-Flow.Likely to cause new Flow errors:
flow get-imports CLI command.Arrays are invariantly typed explanations are now correctly removed.New Features:
Required and Partial to list of utility types to autocomplete in the IDE.Notable bug fixes:
new Foo()).any might have caused this issue.Library Definitions:
process.hrtime.bigint().Notable bug fixes:
Likely to cause new Flow errors:
*, it's just an alias for anyNew Features:
{[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 the experimental.mapped_type=true flag in the options section of your flowconfig.Notable bug fixes:
super.|)o.m(|))unused-promise lint false positives for logical and conditional expressions: with inferred predicates in flow-remove-typesParser:
static prototype fieldsLibrary Definitions:
Misc:
Likely to cause new Flow errors:
$Partial has been renamed to Partial, use the latter instead. Read the blog post for more details.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.$Call and $ObjMap during the check of a polymorphic function call. As a result, more underconstrained errors or type incompatibility errors might appear.sharedmemory.log_level flowconfig option and the --sharedmemory-log-level command line option.IDE:
$Partial to Partial.Notable bug fixes:
empty. e.g. try Flow example..constructor accesses. e.g. try Flow example.underconstrained-implicit-instantiation errors are raised in overloaded function calls. e.g. try Flow exampleany 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.Misc:
Parser:
(, & and | are now included in intersection and union ranges, respectively.Library Definitions:
setState in React lib defs to use $ReadOnly<Partial<T>> instead of $Shape<T>.$ReadOnlySet entry type covariant.Performance typing with the eventCounts property, according to the W3C standard.mark and measure properties on Performance interface according to the W3C standard.Misc:
experimental.channel_mode=socket on WindowsParser:
Likely to cause new Flow errors:
New Features:
['s'] and ['s', 1] are both valid values for [foo: string, bar?: number].exact_by_default=true is now the default value if the option is omitted from the .flowconfig. Read this blog post for more details.Notable bug fixes:
null and void from the inferred type of the parameter. This removes spurious errors like this.prop-missing errors might be removed. Example hereMisc:
module.system.haste.module_ref_prefix_LEGACY_INTEROP in the config to allow migration from the automatic_require_default flag and to ES module syntax.Parser:
(A | B)[].Local Type Inference:
Likely to cause new Flow errors:
null, we use all the assignments to the variables as its initial type. We now no longer consider assignments from a child generic function. As a result, you might get new invalid-declaration errors. Example$Partial will now preserve the variance of the input object type's properties. For example, if the the input was a read-only object, now that output will also be a read-only object (with optional properties).string and symbol are no longer subtypes of an interfacewith statements in non-strict mode. It was already a syntax error in strict mode.New Features:
/**use_mixed_in_catch_variables config option that makes catch variables default to mixed instead of any$Partial utility type to Partial. $Partial will continue working as an alias for at least one more version - use that period of time to codemod it to Partial.Required utility type. It does the opposite of Partial: it makes optional properties required in object types.Object.values on a Flow Enum, to point the user to using .members()number and boolean primitives as a subtype of an interfaceNotable bug fixes:
underconstrained-implicit-instantiation errors that were otherwise impossible to fix.$Keys$Shape utility type to Partial. It is possible that this will create type errors that you will have to resolve.$Partial to PartialMisc:
unused-promise-in-async-scope and unused-promise-in-sync-scope. They can be enabled with unused-promise.--evaluate-type-destructors flag from type-at-pos commandflow save-state --scm flag to ease creation of SCM-aware saved statesParser:
infer a reserved word in typesNotable 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:
missing-local-annot errors on return type annotation positions.any type. Instead, they will be properly contextually typed. e.g. try Flow example.exact_by_default option is now required to be set in the [options] section of the .flowconfig. Add either exact_by_default=true or exact_by_default=false to your [options] section. Previously the absence of the option was equivalent to exact_by_default=false. In the future, we will make the absence of the option equivalent to exact_by_default=true. Read more about the option here: https://flow.org/en/docs/config/options/#toc-exact-by-default-boolean. To create a valid new .flowconfig, use flow init.missing-local-annot error under LTI. e.g. try Flow examplethis type of exported classes' methods are no longer unsoundly typed as any. As a result, more underconstrained implicit instantiation errors might show up in LTI.New Features:
flow autofix missing-local-annot command that will try to add annotations to autofix all missing-local-annot errors in a given file.missing-local-annot errors where we can locally infer a type. Previously, this kind of autofix is only provided for unannotated parameters.unused-promise-in-sync-scope lint which will detect unused promises in sync scopes (like unused-promise-in-async-scope does for async scopes). Enabling unused-promise will enable both of these rules. The individual rules will be removed in a future release.// @flow strict, // @jsx custom_jsx_fun) are now supported in try-flow.IDE:
$FlowFixMe comments.Notable bug fixes:
missing-local-annot when there is a proper typing context in super call. e.g. super(x => x) will now pass type checking under LTI if the super constructor call expects such function.$ReadOnly will no longer shadow your local definitions with the same name.Parser:
function as an alias to Function, and don't allow function as a type name in general. (closes issue #9000).Notable bug fixes:
Likely to cause new Flow errors:
declare function compose<T>(
fns:...$ReadOnlyArray<T=>T>,
): T;
getTime().Array<empty> under LTI. e.g. Array.from(nullableStringArray ?? []). As a result, previously hidden errors might be revealed.missing-local-annot error might be shown in cases when we cannot resolve overload. Exampledeclare function id<T>(T): T;
id([(item) => 1]); // now errors
New Features:
declare let and declare const. These work like declare var, but follow the rules of let and const respectively.Notable bug fixes:
$Compose now works under LTI mode.illegal-this error when a this annotation is used in contextual typing.function f({a: b}): boolean %checks { return typeof b === 'string'; }. Instead, you will only get error on this unsupported syntax.String.raw. (Closes #7580. Fixes #5705. Fixes #2616.)underconstrained-implicit-instantiation errors, when we decide that using type parameter default or bound won't cause downstream errors.Misc:
Parser:
Notable bug fixes:
Parser:
await in async formal parameters (including a regression in 0.198.0)Likely to cause new Flow errors:
unsafe-arithmetic.keyof, undefined, never, unknown, and readonly are now reserved types. If you have a user-defined types of these names, rename them to something else.New Features:
keyof type operator, recommending $Keys<...> instead.undefined type, recommending void instead.never type, recommending empty instead.unknown type, recommending mixed instead.readonly applied to tuple and array type syntax.in/out/in out variance annotations.as, as const, and satisfies cast expressions.flow codemod annotate-implicit-instantiations --include-lti --ignore-suppressed --write .Notable bug fixes:
IDE:
Object.prototype are no longer included in autocomplete results.Parser:
for await (async of ...) (regressed in 0.197.0)for (let in x) in non-strict modestaticawait as a parameter in an async arrow functionexport { ReservedWord as ... }export * as ReservedWord from ..., which is now allowed&& and || as tokens when parsing types to improve error messagestypeof type argument as a value, not a type, as it is a valueLibrary Definitions:
Element.getAttributeNames(): Array<string>Local Type Inference:
We are releasing a new inference mode called local type inference. You can enable this new mode in your codebase by adding inference_mode=lti to the [options] section in the flowconfig. We will describe more details on this inference mode in an upcoming blog post.
Likely to cause new Flow errors:
bool is a deprecated alias for boolean. Added a deprecated-type-bool lint and flow fix --error-codes deprecated-type codemod to help migrate to boolean. This lint is also included in the deprecated-type lint; if deprecated-type is enabled, you can opt out with deprecated-type-bool=offNew Features:
$ReadOnly utility makes tuples read-only. E.g. $ReadOnly<[string, number]> is the same as [+a: string, +b: number].type T = [+foo: number, +bar: string] creates a read-only tuple.mixed or any as an annotation to a catch parameter (but not anything else)Notable bug fixes:
Misc:
any (instead of V$n) in hover types.Parser:
symbol is now a reserved typefor (async of []) is now a parse errorLibrary Definitions:
AbortController and AbortSignal signaturesReactSetStateFunction type introduced in the last release.🎁 This is (hopefully) our lastsecond to last release of the year. Happy holidays! 🎁
saved_state.allow_reinit optionLikely to cause new Flow errors:
mixed, type the result of Object.values and Object.entries on a dictionary to be the dictionary values, and Object.entries keys to behave like Object.keys. Closes #2174, #2221, #4771, #4997, #5838.Object.values and Object.entries.name and length property are now not writable.Object.keys, $Values, and $Keys on interfaces with indexers.$Subtype and $SuperType utilities.deprecated-utility Flow lint.New Features:
export default (3 + 3 : number) can now just be export default 3 + 3;).Notable bug fixes:
any or number.1 or true to be truthy. Before, anything other than 0 and false was considered truthy.Misc:
Library Definitions:
ReactSetStateFunction type alias in react. This is the type of setVal in const [val, setVal] = React.useState(...).Misc:
--experimental.run-post-inference-implicit-instantiation true/false CLI flag
to override the respective experimental flowconfig option.Misc:
unused-promise-in-async-scope lint which will insert void.symbol and bigint to $NotNullOrVoidfindLast to Array definitionLikely to cause new Flow errors:
empty will now properly error, e.g. (E.A: empty).New Features:
unused-promise-in-async-scope lint which will insert await.<, >, <=, >=), update (++, --) and arithmetic operators (+, -, ~, *) to be used with bigints.sketchy-null-bigint lint to match the behavior of the other sketchy-null-* lints for bigints.declare enum and declare export enum. Keep in mind that users need to have enabled Flow Enums if you wish to create library definitions that use them.Parser:
flow_parser OPAM package. Some modules in src/parser/ like Comment_utils are newly available.flow_parser.js by roughly 25%, to 768kb.declare opaque type was parsed as an OpaqueType when interned comments are disabled.New Features:
Notable bug fixes:
module.system.node.root_relative_dirname setting when doing so. Also, scoped package names are now supported in the Haste module resolver.Misc:
module.system=haste, importing packages in node_modules folders now obeys Node's resolution algorithm, rather than being able to be required from anywhere in the project.Library Definitions:
Notable changes:
exact_empty_objects flag and the annotate_empty_object codemod are now deleted, See https://medium.com/flow-type/improved-handling-of-the-empty-object-in-flow-ead91887e40c for more details.inference_mode=experimental.lti to your flowconfig.Likely to cause new Flow errors:
cannot-resolve-name errors now are emitted for every use of an undefined variable, not just the first.New Features:
unused-promise-in-async-scope in the lint section of your flowconfig.Misc:
annotate-use-state and annotate-use-callback codemod commands have been merged into annotate-react-hooks4Library Definitions:
interface {}Likely to cause new Flow errors:
exact_empty_objects option is now enabled by default. Details about this change and how to update your codebase are covered on our blog.typeof X type annotation now respects the initialization state of X: if X hasn't been declared it will be an error to get its type.Notable changes:
enforce_local_inference_annotations config option was removed. To migrate your codebase, run the following codemod to add the required annotations: flow codemod annotate-lti. More details on the changes are explained in the Requiring More Annotations to Functions and Classes in Flow blog post.hg updateNote:
Due to large number of likely new Flow errors that will be introduced in the next release, we decided to create an extra release to ease the upgrade process.
We announced in the recent blog post that we would remove the enforce_local_inference_annotations option in flowconfigs, as it became the default in v0.189.0. This change will be delayed to v0.191.0 instead.
Likely to cause new Flow errors:
extends clauses in class definitions are either variables, casts, or member expressions, rather than allowing arbitrary expressions.any and type applications like Promise<T>, which may cause new downstream errors to be discovered.Notable bug fixes:
Likely to cause new Flow errors:
enforce_local_inference_annotations is now on by default. To migrate your codebase run the following codemod to add the required annotations: flow codemod annotate-lti. More details on the changes are explained in the Requiring More Annotations to Functions and Classes in Flow blog post.New Features:
this is not typed explicitly.Notable bug fixes:
object-this-reference errors. Previously these errors were missing when the object is an argument of Object.freeze(), Object.defineProperties() or Object.create().Library Definitions:
fs.readFile type definition when the encoding config option is supplied.Bug fixes:
Performance:
Bug fixes:
Misc:
flow codemod annotate-lti to flow codemod annotate-functions-and-classes to clarify that this is not the only codemod necessary for enabling LTI eventually.Likely to cause new Flow errors:
new SomeClass:new SomeClass.
This is confusing, and we dropped support for this feature in this release. Now we enforce that all class constructors must return void.&& expressions: examples like typeof x === 'number' && reassignXToString() && (x: number) were passing even if reassignXToString() assigned a a string value to x.New Features:
flow codemod annotate-lti is now provided to help prepare your codebase to enable the enforce_local_inference_annotations=true flag. In order to eventually enable local type inference, we will require additional annotations in places we can't contextually type your code. You can enable the annotation enforcement now with enforce_local_inference_annotations=true in flowconfig. This flag enables the behaviors of all the following experimental flags, which will be deleted in the next release:experimental.enforce_local_inference_annotations=true
experimental.enforce_this_annotations=true
experimental.enforce_class_annotations=true
To migrate your codebase, you can run the following codemod to prepare your codebase for the new requirement: flow codemod annotate-lti. Check out an upcoming blog post for more details.
Misc:
file_watcher.watchman.survive_restarts flowconfig option, which was deprecated in 0.158.0. We will always try to survive Watchman restarts.experimental.refactor flowconfig option. It has been true by default since v0.158.0.Library Definitions:
Likely to cause new Flow errors:
@jsx Foo.bar) will no longer be incorrectly considered as unreachable. This might uncover previously hidden errors.New Features:
foo|Baz (cursor at |) and choose fooBar, you'll now get fooBarBaz instead of fooBar. In VS Code, you can press shift-enter to replace instead of insert.Bug fixes:
declare module exports (D38977152 mroch)flow get-def --json to write {"error": message} to stdout on error, instead of writing non-JSON to stderrLibrary Definitions:
import.meta. They are typed as mixedNotable breaking changes:
inference_mode=classic has been removed. The default is now inference_mode=constrain_writes. Please refer to the blog post for migration paths. Additionally we have removed all codemod commands that depend on the classic inference mode. This includes the annotate-declarations, rename-redefinitions and annotate-escaped-generics codemods.Likely to cause new Flow errors:
this in object getters and setters are now banned. Referencing this in object methods are already banned, and this change makes Flow's behavior more consistent.Notable bug fixes:
Library Definitions:
PerformanceServerTiming definition and the serverTiming attribute to PerformanceResourceTiming.New Features:
@jsxRuntime pragma in the top docblock of each JS module. Allowed values are classic and automatic.Misc:
autoimports_ranked_by_usage=true)Likely to cause new Flow errors:
x = some expression containing x have a type that's effectively any. If you turned on inference_mode=constrain_writes since the last release, there will be new errors.esproposal_export_star_as as an option and make this the default as it made it into the JS standard in 2018.value-as-type errors might be emitted, as a result of existing importing errors.New Features:
inference_mode=constrain_writes will be the default. inference_mode=classic, which is the current default, will be removed in the next release. Please refer to the blog post for migration paths.Misc:
Library Definitions:
.x and .y properties to DOMRect. (Thanks @pmer)Upcoming Breaking Changes:
New Inference Mode:
We are releasing a new inference mode that marks significant progress on our way to local type inference. You can enable this new mode in your codebase by adding inference_mode=constrain_writes to the [options] section in the flowconfig.
We will make inference_mode default to constrain_writes in v0.185, and remove the classic option in v0.186. To migrate your codebase, you can run the following codemods to prepare your codebase for the new inference mode:
flow codemod rename-redefinitions
flow codemod annotate-declarations
We will describe more details on this inference mode in an upcoming blog post.
Additional Annotation Requirements:
In order to eventually enable local type inference, we will require additional annotations in places we can't contextually type your code. You can enable the annotation enforcement now with the following flags in flowconfig:
experimental.enforce_local_inference_annotations=true
experimental.enforce_this_annotations=true
experimental.enforce_class_annotations=true
To migrate your codebase, you can run the following codemod to prepare your codebase for the new requirement: flow codemod annotate-lti-experimental
Likely to cause new Flow errors:
Object.create now results in a sealed object. Arbitrary properties can no longer be read/written from/to it. You can use the __proto__ property in object annotations to create an annotation if you need to.Notable bug fixes:
function emit(...args: [{+bar: string}]): void {}
emit({ bar: "" }); // no longer emits incompatible-variance
flow-upgrade:
exact_empty_objects flowconfig optionLibrary Definitions:
Likely to cause new Flow errors:
New Features:
exact_empty_objects is enabled.useState codemod to support null/undefined/empty-array arguments.Notable bug fixes:
Parser:
Library Definitions:
fs.readdir and fs.readdirSync to allow better overload resolution.String.prototype.replaceAll() (Thanks @dav-s).Likely to cause new Flow errors:
var re-declarations are now banned. You should use let or const instead.Notable bug fixes:
Misc:
--saved-state-verify flag to check that a saved state matches what is expected to be on disk.Notable bug fixes:
Notable bug fixes:
Parser:
Library Definitions:
v8 moduleNotable bug fixes: Reverted changes that cause Flow to generate a corrupted saved-state when libdef changes.
Likely to cause new Flow errors:
next parameter to void. If a non-void next type is desired for a function, it will have to be annotated.experimental.enforce_local_inference_annotations is enabled, Flow now requires annotations on functions returned from async or generator functions.New Features:
experimental.enforce_local_inference_annotations is enabled, Flow now has a code action to auto-annotate parameters of functions that have missing-local-annot errors.Notable bug fixes:
import type * ..., export async ... statements or nameless named exports.Misc:
--no-enums flag to flow ast.Parser:
"use strict"Library Definitions:
Navigator.canShare().Likely to cause new Flow errors:
Notable bug fixes:
\/. This could have broken IDE integrations while typing.Parser:
d RegExp flag (see RegExp Match Indices).Library Definitions:
Notable Bug Fixes:
e.g. import '') is added.Likely to cause new Flow errors:
require, since requiring a module can have side effectsNew Features:
useId, useInsertionEffect and useSyncExternalStoreNotable bug fixes:
x instanceof A when x is typed as any refines it to A instead of empty[include] entries containing both globs and relative paths on WindowsParser:
export interface ... or export enum ...Likely to cause new Flow errors:
any typedinterface {}name === 'literal' and name.prop === 'literal' complaining that literal is incompatible with the type of name or name.prop.interface {} rather than $NotNullOrVoid; number and boolean inputs will now errorNew Features:
useState when it is called with an empty object. Use with flow codemod annotate-use-stateNotable bug fixes:
literal is a subtype of expr in expr === literal, regardless of whether expr === literal can be applied as a refinementParser:
Library Definitions:
Notable bug fixes:
module.system=haste and have both a @providesModule foo file (or use "haste paths" to derive the module name from its filename) and a node_modules/foo folder, require('foo') will now resolve to the Haste module, even when node_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.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:
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 a declare class.Notable changes:
React.createClass from Flow. It is now just typed as any. Migrate any components using it to class components or function components.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 run command to generate it (and resolve the error).Bug fixes:
flow stop to kill stuck serversNotable changes:
for loopsFLOW_CONFIG_NAME env as alternative to passing --flowconfig-namefile_watcher.mergebase_with.{git,hg} configs to support projects accessible via multiple VCSs (e.g. git mirrors of hg repositories)IDE integration:
require()flow-remove-types:
this param with trailing commasFix crash when Flow receives duplicate file deletion notifications introduced in v0.174.
Likely to cause new Flow errors:
New Features:
void, instead of an error.Notable bug fixes:
declare function that comes after a function declaration of the same name (try-Flow).this-in-exported-function for functions with a this parameter.Misc:
--list-files flag to status and check commands. This will dump a list of files that contain errors instead of the error messages..dfind_log file alongside the .log and .monitor_log files.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:
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:
Notable bug fixes:
Misc:
Parser:
< (e.g., f<<T>()=>S>()) would be incorrectly parsed as the left shift operator.Library Definitions:
util.typesBug Fixes:
$Values<> types in an export position (e.g. Try Flow)module.file_ext when resolving imports. Before, they were tried alphabetically.Misc:
signature-verification-failure from a lint to a normal error. It is no longer valid in the [lints] section of .flowconfig.Likely to cause new Flow errors:
experimental.new_merge option becomes true 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:
Parser:
export * as x from 'y' is now an ExportAllDeclaration with an exported key.esproposal_nullish_coalescing option.esproposal_optional_chaining option.esproposal_class_static_fields option.esproposal_class_instance_fields option.Library Definitions:
options parameters in node's fsPromises optional.Another light release due to the new year. Changes are mainly internal -- refactoring or progress towards future features.
Notable breaking changes:
This release is light on changes due to the holidays. Happy New Year!
Notable bug fixes:
Notable bug fixes:
Notable bug fixes:
@flow modesMisc:
--profile, --json and --pretty flags from flow force-recheckLibrary Definitions:
flow check-contents on non-Flow files by default; pass --all to force it.--weak CLI flag and weak=true flowconfig option have been removed.Notable bug fixes:
Likely to cause new Flow errors:
declare var syntax be annotated with a type. declare var x; is now illegal.Notable bug fixes:
flow autocomplete on non-Flow files.export default class definitionsNew 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 reference foo instead, or just use ES modules (e.g. export const foo = ...)typeof type annotations.$ElementType and $PropertyType utilities.indexed_access option, it's always enabled now (was on by default before if the option was omitted).Notable bug fixes:
refactor code-action would hang on large inputs.import typeof Foo rather than import type {Foo}watchman on Windows.$ExactT<...> type annotations.this in a JSX title member.flow coverage now returns 0% for non-@flow files; pass --all to also check non-@flow files.flow get-def on non-Flow files.flow type-at-pos on non-Flow filesCompletionItemLabelDetailLibrary Definitions:
navigator.clipboard.write type and add ClipboardItem (thanks @Egrodo).fs.copyFile overload to support the case where the mode param is not specified (thanks @Brianzchen).Misc:
flow suggest command.flow find-refs command.--expand-type-aliases flag from all Flow commands, it has caused several performance and non-termination issues without providing much value.Parser:
typeof type annotations, where the argument to typeof is a not a variable or member expression, are now parse errors rather than type errors.New Features:
* type is now an alias to any. You can use flow 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.flow ast command.Notable bug fixes:
$KeyMirror so that it respects the optionality of its arguments.JSON as object rather than a class. This prevents code such as new JSON() which is a runtime error.Library Definitions:
InputEvent.dataTransferAggregateError class - fixes #8764 (thanks @lachlanhunt).UIEvent, InputEvent and KeyboardEvent types.Misc:
Parser:
# in private identifiers.experimental.prioritize_dependency_checksnode_modules were shown in lazy mode. It is now consistent with non-lazy mode.Likely to cause new Flow errors:
null (let x: null = null); if only undefined, then it can be annotated with void (let x: void;).New Features:
$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:
strict_es6_import_export--autostopMisc:
import.meta as objectdeclare functionformat.single_quotes settingexperimental.prioritize_dependency_checksLikely to cause new Flow errors:
string and number, as well as utility types like $Call and $Keys.Notable changes:
Notable bug fixes:
[lints] section are now ignored when passing --ignore-version.$ReadOnly types.flow-remove-types:
flow-remove-types/jestNew Features:
The ide, fs and watchman 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 to file_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=watchmanlazy_mode=fs -> lazy_mode=truelazy_mode=ide -> lazy_mode=truelazy_mode=none -> lazy_mode=falseAdded parser support for import.meta
Added type checking support for new.target and import.meta as mixed
Library Definitions:
queueMicrotaskNotable bug fixes:
New Features:
file_watcher=watchman and lazy_mode=fs can now upgrade to lazy_mode=watchman.$ObjMapi<T, <K>(K) => K> to $KeyMirror<T>. Run it via flow codemod key-mirror [OPTION]... [FILE].Library Definitions:
devicePixelRatio global (thanks @Brianzchen)New Features:
Notable changes:
#foo: () => 'foo' could not be called, leading to workarounds like this.#foo.call(this)$NonMaybeType<...>module.system.haste.module_ref_prefix=m#, "m#Foo" will jump to the Foo module)file_watcher.watchman.survive_restarts setting is now true by default. This setting is deprecated and will be removed in a future version.--retry-if-init CLI flag has been removed. Setting it to false 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:
flow-remove-types:
Likely to cause new Flow errors:
break and continue branches.New Features:
experimental.refactor=false to the .flowconfig. (thanks to our intern, @SamChou19815)eslint-plugin-fb-flow, for eslint rules from the Flow team. The first rule is use-indexed-access-type to encourage the use of indexed access types (https://flow.org/en/docs/types/indexed-access/).update-suppressions to the flow tool (fixes #8384).Library Definitions:
Misc:
New Features:
0.143.0. Can be disabled per project with the autoimports=false flowconfig option, or per user with the flow.suggest.autoImports LSP configuration.Library Definitions:
Fix bug in shared memory garbage collection which caused Flow to crash.
Likely to cause new Flow errors:
this inside of object methods (see https://medium.com/flow-type/sound-typing-for-this-in-flow-d62db2af969e).Notable bug fixes:
$ReadOnly utilityLibrary Definitions:
Likely to cause new Flow errors:
this parameters of functions (see https://medium.com/flow-type/sound-typing-for-this-in-flow-d62db2af969e).New Features:
*). It can be run via flow codemod replace-existentials --write ..Notable bug fixes:
Library Definitions:
Misc:
experimental.this_annot config option and permanently enable now that our core lib defs rely on this feature.new_check config option for the new check mode that uses significantly less RAM for large projects.Likely to cause new Flow errors:
this typing by banning the unbinding of class methods (see https://medium.com/flow-type/sound-typing-for-this-in-flow-d62db2af969e).New Features:
// flowlint-next-line require-explicit-enum-switch-cases:error.flow fix command to apply autofixes from the command line to a list of files.Notable bug fixes:
--ignore-version flag also prevents Flow from crashing when an invalid option is in the .flowconfig.Library Definitions:
options parameter for require.resolve. (thanks @skeggse)void from TypedArray sort function. (thanks @goodmind)DOMStringList instead of a string array from IDBDatabase.objectStoreNames. (thanks @bnelo12)Misc:
--binary to the flow version command to see the path to the current binary..flowconfig.method-unbinding error to replace the method with an arrow function.class-object-subtyping error to replace the object type with an interface.Likely to cause new Flow errors:
Notable bug fixes:
Library Definitions:
Symbol.asyncIterator (thanks @goodmind)HTMLTableSectionElement (thanks @vitoreiji)MediaRecorder constructor optionscrypto types (thanks @juodumas)cluster.worker type (thanks @magicmark)New Features:
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 latest flow-enums-runtime package.Notable bug fixes:
annotate-exports codemod to add lowercase react instead of React (thanks @meandmax!).Misc:
README.md.cache_live_errors_artifacts and cache_signature_help_artifacts config options by default.super outside of class methods added in 0.148.0 has been removed.Library Definitions:
Map, WeakMap, Set and WeakSet constructors' iterable param to be optional as per the ECMAScript spec.PageTransitionEvent as per the HTML spec (thanks @bripkens!).stepUp and stepDown in HTMLInputElement declaration as per the HTML spec.New Features:
Notable bug fixes:
package.json to have a valid Flow extension for the file to be considered..js extensions even when a module name looks like a resource file (e.g. ./a.svg will look to ./a.svg.js).this parameter with a generic.$NonMaybeType<empty> evaluate to empty.PointerCapture library definitions (thanks @malectro!).Misc:
observedBits param to React's useContext libdef.format.bracket_spacing option which affects code output (such as code actions).New Features:
Notable bug fixes:
obj[Symbol.iterator]. This is now correctly typed as the object type's @@iterator property.Misc:
esproposal.class_instance_fields, esproposal.class_static_fields, esproposal.decorators, esproposal.export_star_as, esproposal.nullish_coalescing and esproposal.optional_chaining flowconfig options which have been deprecated since v0.135.Likely to cause new Flow errors:
x instanceof null. This catches 'instanceof' is not an object runtime errors.super outside of class methods, e.g. in arrow and function properties, is now an error.Library Definitions:
static from to stream$Readable (thanks @agalatan).Notable bug fixes:
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 LSP textDocument/rename request.experimental.new_signatures flowconfig option as well as the --old-signatures opt-out command line flag.Likely to cause new Flow errors:
?{c: number} did not properly error when used with utility types $PropertyType and $ElementType. null and undefined do not have properties nor elements.Object.prototype properties like toString and hasOwnProperty are no longer allowed to be accessed as global variables, which was previously allowed because window is an object.New Features:
flow-bin.Notable bug fixes:
null and undefinedflow lsp on symlinked root directoriesMisc:
@flow weak, which was a rarely-used mode in which missing annotations were treated as any. It is equivalent to suppressing any type errors that result from just using @flow. So to migrate, suppress the new errors and remove weak.flow.suggest.autoImports LSP setting to disable autoimport suggestions in autocomplete (currently requires autoimports=true to be enabled in .flowconfig)Library definitions:
assert strict mode (thanks @goodmind).webp resources (thanks @TomasBarry)tty.WriteStream (thanks @reyronald)process.exit to return emptyParser:
Likely to cause new Flow errors:
interface {} is no longer a supertype of void and mixedNotable bug fixes:
. were sometimes being ignored by Flow, which has now been fixedLibrary Definitions:
PerformanceResourceTiming library definition (thanks @MIGreenberg)withFileTypes option to readdir and readdirSync (thanks @mrtnzlml)composedPath function to Event library definition (thanks @Brianzchen)Event library definition and made most properties read-onlyMisc:
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, and gc.worker.window_size.Likely to cause new Flow errors:
function i({name = 1}: {| name?: string |}) {} was previously not an error.New Features:
flow_parser.js to support configuring comment output. comments enables comment attachment and all_comments enables the legacy list of all comments.Notable bug fixes:
node_modules for auto imports.import type { type T } ...generate_tests=true flowconfig option have now been removed.&&, ||, ??) and union typeslet {foo, ...rest} = obj) now retain the indexer of the object being destructured. In this example, if obj is {[string]: string}, then rest is also {[string]: string}.autoimports=true flowconfig option.touch-ing the .flowconfig without changing itNotable bug fixes:
Likely to cause new Flow errors:
types_first and well_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.New Features:
autoimports=true flowconfig option.--sharedmem-heap-size CLI flag and FLOW_SHAREDMEM_HEAP_SIZE environment variable, which can be used instead of the sharedmem.heap_size flowconfig option for setting the amount of shared memory available.Misc:
ErrorEvent library definition (thanks @kegluneq)Likely to cause new Flow errors:
Notable bug fixes:
No available version of ocaml-base-compiler satisfies the constraints error from make all-homebrew (thanks @bayandin).Array methods. For example, given [1, 2].map(a => a).forEach(b => b), Flow now infers that b is a number rather than any | number._= in JSX attributes that already have oneLikely to cause new Flow errors:
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:
Parser:
Misc:
ShadowRoot library definition (thanks @Brianzchen)New Features:
this annotations in functions, like function f(this: {foo: string}, param1: string): string { return this.foo; }experimental.abstract_locations config option is now true by default, as it enables significant performance improvements. This option is now deprecated and will be removed in a coming version.Notable bug fixes:
K: string flows into $Keys<{[K]: ...}>K: 'literal' is checked against itself like k === 'literal'Misc:
flow-remove-types to support this parametersLikely to cause new Flow errors:
Bug Fixes:
$ExactEditor Integration:
all=true (thanks @mochja)flow CLI at the same time as VS Code caused by case-insensitivity of Windows pathsLibrary Definitions:
inputType to InputEvent (thanks @Brianzchen)intersectsNode to Range (thanks @Brianzchen)Misc:
/tmp/flow/flowlibs_<HASH>, to take up less space.New Features:
Notable bug fixes:
Library Definitions:
Buffer.write to number (thanks @fedotov).Misc:
Likely to cause new Flow errors:
Notable bug fixes:
Requires_not_found or Sig_requires_not_found.Misc:
propTypes to React.AbstractComponentStatics (thanks @brianzchen).Likely to cause new Flow errors:
Misc:
Likely to cause new Flow errors:
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:
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.Misc:
Likely to cause new Flow errors:
New Features:
Notable bug fixes:
flow focus-check when a focused file has a syntax error.Misc:
null-void-addition lint now that it has been subsumed by an ordinary type error.export *itemType and inlineDetail fields from the LSP completionItem implementation.Likely to cause new Flow errors:
New Features:
Notable bug fixes:
Misc:
module in ES modules when well_formed_exports is enabled.types_first=true) when using well_formed_exports.include. For types-first to function properly, the entire project's exports must be well-formed, not just specific paths.--types-first on the command line overrides well_formed_exports=false in .flowconfig. This makes it easier to test types-first mode.unsafe-addition lint now defaults to being an error. It will be converted from a lint to a type error in the future.dynamic-export lint which does not work in types-first modeNew Features:
module.exports = ... to the actual definition.Library Definitions:
offset an optional argument for the sized Buffer read/writes (thanks @isker!)Misc:
includes/excludes instead (see updated docs: for Types First and flowconfig options).Likely to cause new Flow errors:
Notable bug fixes:
Misc:
cast and isValid to take in optional representation type for enumsNew Features:
default were exported with export default syntax.Library Definitions:
Parser:
Config:
Misc:
Library Definitions:
.flowconfig or package.json and then running flow status would get stuck in a restart loop, if using lazy mode with Watchman and Mercurial.window/showStatus responsesHeadersInit and signal to Fetch API (thanks @andretshurotshka!)replace method to DOMTokenList (thanks @w01fgang!)Publishing of flow-bin v0.125.0 failed to include the binaries. Oops!
Likely to cause new Flow errors:
any.New features:
Notable bug fixes:
empty in some circumstances.Misc:
$FlowIssue and $FlowExpectedError as default suppression comments.type-at-pos and friends.Parser:
type keyword in type aliases.Library definitions:
thisArg parameter for array callback functions (e.g. map, reduce) to mixed.Array.flat.Library Definitions:
StorageEvent overloads.Misc:
textEdit in identifier completion item responses over the LSP, to avoid possible behavior differences with different LSP clients.Parser:
flow-dev-tools:
update-suppressions subcommand.New Features:
react.runtime flowconfig
option. When set to automatic the transform auto-imports jsx (the replacement for
createElement) under a fresh name (unique of all existing names in the source).
When set to classic it will continue transpiling jsx to React.createElement.Notable bug fixes:
$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.Misc:
$Exports<'m'> will now lookup module 'm' directly in builtins, instead of the
environment.Parser:
Likely to cause new Flow errors:
Moved react-dom modules out of built-in libdefs. They are now available on flow-typed.
To install the libdefs, run flow-typed install --flow-version=0.122.0 [email protected]
This diff is necessary to allow React to make breaking changes to react-dom without force-pinning Flow users to the latest version of react-dom.
Fixed an unsoundness in union and intersection spreads
Improved object spread-related error messages, which may cause suppressed errors to become unsuppressed because they moved to better locations
Improved Editor Integration:
f<tab> might complete foo(aParam), which is problematic if you don't want to call the function. Now it just completes foo. These snippets are further obviated by signature help, which appears when you type (.export { HERE } from ...)Misc:
HTMLUnknownElement and support for custom elements to document.createElement (thanks @YevhenKap!)--saved-state-no-fallback flag so that Flow exits when saved state is not foundexperimental.types_first now implies experimental.well_formed_exportsParser:
RestProperty to RestElement to match estreeForAwaitStatement to ForOf with await: true to match estreeHighlights:
Misc:
add-comments script to add comments on JSXText.flow files without @flowLib defs:
url.parse function (thanks @chicoxyzzy)console methods (thanks @goodmind)Element.hasAttributes()string index to NamedNodeMapElement.querySelector() and Element.querySelectorAll() overloadsPromise.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 primitive typeof 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 to undefined and Babel 8 will start to leave them. To maintain existing behavior, change uninitialized fields to use the declare keyword, signalling to Babel that they should be stripped (class C { declare foo: string }).
Notable bug fixes:
type-at-pos and signatureHelpMisc:
Notification to have read-only fieldsNotable bug fixes:
New Features:
new expression.Misc:
minimal_merge flagParser:
new expressions optionalNew Features:
unsafe-addition, which warns if either operand of an addition is null or voidBreaking change:
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:
dir field to the Document libdef (Thanks, @lukeapage!)file_watcher_timeout .flowconfig option and --file-watcher-timeout argument to flow start and flow server, which defaults to 120 seconds.Notable bug fixes:
$Diff and other type destructors when applied to unions.Misc:
Symbol from libdefs in favor of symbol.fs.promises.mkdir (thanks @gabrielrumiranda!)Notable bug fixes:
New Features:
Misc:
Array.prototype.flat (#8237, thanks @nnmrts!).empty rather than any.Parser:
> and } in JSX child text is a parse error.Likely to cause new Flow errors:
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).non-array-spread lint, and replaced it with a new .flowconfig option, babel_loose_array_spread.Notable bug fixes:
$Exact<T> failed when T resolved to a Shape<T>. [example]Misc:
tool add-comments by
flowlint-next-line instead of adding full $FlowFixMe suppressions on lints, andUpgrade 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:
if (x?.y) and if (x?.y === 42) understand that x is truthy in the consequent. Flow also now refines subexpressions of optional chains. For example, given obj?.fun(obj.value), the second obj is known to be truthy since it is only reachable if the earlier obj?.fun is also truthy; therefore, you don't need to optional-chain it again (obj?.value).New Features:
symbol! Note that just like number is not a Number, and vice versa, symbol is not a Symbol. In the core lib defs, we change usage of Symbol to symbol & Symbol. Eventually, it will just be symbol. The symbol & Symbol is temporary for one version to allow for existing usage of the : Symbol to be codemodded to : symbol.Bug fixes:
$ElementType, that led to printing empty instead. This improves hover tooltips.Bug fixes:
signature-verification-failure) out when running flow check-contentsParser:
export default class implements Foo {} [example]Library definitions:
navigator.mediaDevices.getUserMedia (thanks @thecotne)InputEvent to removeEventListenerServiceWorkerContainer.getRegistrationMisc:
module.system.node.main_field option (see #8128 for more details)Likely to cause new Flow errors:
New Features:
ambiguous-object-type lint warning against use of {} object types (prefer {||} or {...} instead, even when exact-by-default is enabled).Notable bug fixes:
unclear-type lint errorMisc:
useDeferredValue and useTransition to React library definitionsbytesWritten function to library definition (thanks @farzonl)Notable bug fixes:
Notable bug fixes:
New features:
module.system.node.root_relative_dirname to allow you to configure where root relative paths resolve toNotable bug fixes:
Likely to cause new Flow errors:
New features:
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.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:
module.system.node.resolve_dirname=.. For those who relied on this bug to import modules using root-relative paths, you can now use module.system.node.allow_root_relative=true. See #8156 for more details.Misc:
flow status, flow check, etc. to choose character offset styleParser:
Notable bug fixes:
all=true in the .flowconfigNew Features:
experimental.disable_live_non_parse_errors=true to the [options] section of your .flowconfig.Notable bug fixes:
[declarations] configuration in the presence of dependency cycles (thanks @STRML!)Misc:
--evaluate-type-destructors to type-at-pos command.--evaluate-type-destructors and --expand-type-aliases to dump-types command (thanks @goodmind!)process.env values from ?string to string|void (thanks @FireyFly!)* typeLikely to cause new Flow errors:
delete, but now doesObject.defineProperty and similar methods now adhere more closely to the specNotable bug fixes:
$NonMaybeType<mixed> no longer includes null and undefined (Thanks @goodmind)Misc:
$Supertype and $Subtype utilities are now removed entirelyPerformance:
Library Definitions
HTMLStyleElement.sheet type (Thanks @kof)AsyncIterator to node.js (Thanks @goodmind)undefined to prelude (Thanks @goodmind)Notable bug fixes:
$ObjMap, $ObjMapi, $TupleMap, and $Call with incorrect arity.Misc:
flow ide command and associated machinery have been removed.Library definitions:
undefined to the prelude.New Features:
Notable bug fixes:
%checks (#7863).Misc:
textDocument/documentHighlight request serviceable while Flow is in the middle of a recheck.--traces flag.undefined is involved.flow lsp is started while the server is initializing.Library Definitions:
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:
?? operator. It now has a lower precedence than || and &&, and parentheses are required to nest it with them.<a:b prop={"hello" * 10} /> now errors)Notable bug fixes:
munge_underscores flowconfig optionMisc:
Parser:
break statements and array patternslibflowparser now supports esproposal_nullish_coalescing as an optionv0.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 typed
any are now typed ProgressEvent; some properties now have null 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 to flow 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:
Misc:
Parser:
Likely to cause new Flow errors:
Function.prototype.apply to only accept array-like objects, not any iterable.New Features:
non-array-spread lint rule: Fires when a non-array iterable is spread. This is useful for modeling the loose: true mode of @babel/plugin-transform-spread, where such code causes a runtime error.Notable Bug Fixes:
implicit-inexact-object linter.Misc:
psflow check --profileflow-remove-types:
declare exportParser:
await to be a parameter in async functionsNew Features:
--types flag to flow cycle, when given only type dependencies are used to compute cyclesNotable bug fixes:
Performance:
Library definitions:
Object and Function (which are aliases for any) in library definitions with anyany from library definitionsMisc:
Likely to cause new Flow errors:
MixedElement export into the module declaration, so it will now need to be qualified as React.MixedElement.Notable bug fixes:
$ObjMap).Misc:
defaultProps property and make them compatible with React.AbstractComponent.BigInts. (thanks, @goodmind!)rc.Libdefs:
Object type (equivalent to any) from WeakSet and $ReadOnlyWeakSet. (thanks, @goodmind!)Notable bug fixes:
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:
... to the
end of the props list. See here for context.Notable bug fixes:
Misc:
React.memo and React.lazy now both allow you to specify an instance type via React.AbstractComponent.recursion_limit. Most projects will not need to override this value.Parser:
#constructorLikely to cause new Flow errors:
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, use React$ComponentType instead. Try Flow exampleReact$ComponentType annotation is now strict when used with refs. Before, it was possible to pass a ref having any type when creating an element from a component using this type. If you need to describe components that accept refs, use the React$AbstractComponent type instead. Try Flow example$Enum built-in type annotation is now deprecated. Please use the semantically equivalent $Keys type instead.New Features:
React$MixedElement as the sound superclass of all React elements. This is a type alias for React$Element<React$ElementType>.Misc:
decode method to HTMLImageElement (thanks, @vicapow!)Parser:
Notable bug fixes:
Likely to cause new Flow errors:
any but are now typed as an empty object.$call property syntax, deprecated in Flow v0.75, has finally been removed.Notable bug fixes:
Misc:
Parser:
Notable bug fixes:
Likely to cause new Flow errors:
void before typechecking starts for functions without a return statement, lessening the impact of a union typechecking bug (#7322).deprecated-utility lint on by default.mixed refined to an array produces a read-only array.mixed refined to an object produces a read-only object.New Features:
.flowconfig (#7317).Notable bug fixes:
untyped-import lint rule so that export [type] * from triggers it.Misc:
deprecated-utility and dynamic-export lints when applying all=setting rules (#7473).$ObjMap or $ObjMapi (#7642).flow type-at-pos --json.DidOpen notifications from the IDE in order to make checking in IDE lazy mode more efficient.flow lsp automatically starts a server, it prefers the lazy mode set in a .flowconfig to the lazy mode passed on the CLI.this type is used incorrectly.React.Element behave differently than React$Element.any.Libdefs:
document.elementsFromPoint() (#7540).ConstantSourceNode (#7543).React.Suspense maxDuration attribute (#7613).Likely to cause new Flow errors:
mixed with instanceof A produces type A instead empty which was produced before.declare module are no longer automatically exported from that module as well.New Features:
Notable bug fixes:
flow coverage is passed an invalid input path.Misc:
typeof, tuples and interface types). The mapper got support for qualified identifiers.$Diff, etc. This should lead to more compact results.Library definition improvements:
Parser:
Likely to cause new Flow errors:
Recently the Object and Function types changed their meaning from "any function type" to "any
type." Accordingly, various Object and Function 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 and Object 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. Running
batch-coverage in lazy mode is now disallowed.
Fixed an issue with flow lsp where logs would not be flushed.
React.createClass({}) will contain defaultProps: void, instead of defaultProps: {||} (unsealed empty object).JSON.stringify allowing mixed input, which returns string | void. Without this, you can't call JSON.stringify on a mixed value at all, because while Flow does allow refining mixed to "not void" (e.g. x === undefined ? undefined : JSON.stringify(x)), it does not support refining mixed to "not a function" (e.g. imagine you could do x === 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:
undefined and functions in JSON.stringify: JSON.stringify(undefined) returns undefined instead of string. Rather than make it always return string | void, or use overloads to return void 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:
Other improvements:
Bug fixes:
dynamic-exports lint's spurious errors on exported classes and functionsPerformance:
Many libdef fixes and other improvements from the open source community:
Proxy$traps (thanks @talbenari1!)Additional lib def improvements:
current write-only in React.Ref - allowing union types for refsetMediaKeys API to definition of HTMLMediaElementhttp$Agent covariantLikely to cause new Flow errors:
any types and React proptypes for efficiency. This may result in some errors no longer being reported.New Features:
dynamic-export) which when enabled will warn when most dynamic types are exported from a file.any and empty when computing line coverage. empty types are colored blue and any types red when using the --color option. Note that this may cause new expressions to be considered uncovered.Notable bug fixes:
this-substitution.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!
InputEvent(Listener|Handler|Types|) (thanks @keithamus!)IntersectionObserver constructor definition (thanks @apostolos!)ServiceWorkerMessageEvent extend ExtendableEvent (thanks @keyiiiii!)module.builtinModules to core libdef (thanks @simenB!)writable.setDefaultEncoding() (thanks @dnalborczyk!)util.callbackify to node type def (thanks @dnalborczyk!)BroadcastChannel (thanks @schmatz!)timingSafeEqual() (thanks @rolftimmermans!)destroy method to streams (thanks @hiikezoe!)XMLHttpRequest (thanks @robin-pham!)AnimationEvent (thanks @ngyikp!)Object.getOwnPropertyDescriptors (thanks @disnet!)EventEmitter API definition (thanks @antongolub!)Element.prototype.toggleAttribute (thanks @keithamus!)TransitionEvent to dom libdef (thanks @koddsson!)appendFile, appendFileSync (thanks @cappslock!)navigator.serviceWorker (thanks @dhui!)Uint8Array (thanks @cakoose!)dns.lookup() (thanks @shuhei!)https interfaces (thanks @cakoose!)createContextualFragment return a DocumentFragment (thanks @wincent!)oncontextmenu to HTMLElement (thanks @jasonLaster!)MediaDeviceInfo declaration (thanks @ea167!)userSelect to CSS declaration (thanks @shubhodeep9!)fs.promises.readFile being incorrectly overloaded (thanks @Macil!)EventSource to dom libdef. Likely to cause new errors (thanks @SlIdE42!)XDomainRequest in bom libdef. Likely to cause new errors (thanks @Mouvedia!)displayName property to React$Context (thanks @bvaughn!)typeof x === 'symbol' (thanks @mroch!)useRef type non-nullable (thanks @trysound!)Stream type to Node thanks (thanks @goodmind!)Misc:
Notable bug fixes:
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.
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!
React.memo now accepts any kind of ComponentLikely to cause new Flow errors:
New Features:
--lazy-mode flag was added to all commands that may autostart a serverNotable bug fixes:
Misc:
Likely to cause new Flow errors:
Pull Requests:
Notable bug fixes:
Parser:
Likely to cause new Flow errors:
React.forwardRef and better typing higher-order components. Docs are available here.New Features:
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-rootMisc:
flow gen-flow-files due to bitrot. We do plan on building a better version in the future.{} now consistently represents an unsealed object. You can read more in the documentation. exampleLikely to cause new Flow errors:
Function and Object types be aliases for any. They were always unsafe types, just like any, 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:
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.flow config check which validates the .flowconfig.Misc:
.flowconfig parsing less strict (in particular, if the --ignore-version flag is passed, do not fatal on unrecognized config options).type-at-pos to be displayed differently.string, rather than the singleton type of that literal. Now, this fact is surfaced in error messages.Libdefs:
React.Suspense.React.useMutationEffect hook.Likely to cause new Flow errors:
React.createRef definition. Refs are for any type of value,
not just React elements.New Features:
flow config find command that
finds the .flowconfig governing path.Notable bug fixes:
flow ls --json command.Misc:
flow port command.JSX.frag_closingElement of the AST to not be an option.import type and import typeof with default.Library definition changes:
PositionOptions optional.calculateChangedBits parameter to the React.createContext definition.React.ConcurrentMode and React.StrictMode definitions.React.lazy and React.memo definitions.Parser:
Likely to cause new Flow errors:
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 _.$ReadOnlyMap, $ReadOnlyWeakMap, $ReadOnlySet, and $ReadOnlyWeakSet. These types and their mutable counterparts mostly follow the pattern of $ReadOnlyArray and Array: 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.React.StrictMode type.flowtest package. flowtest is a CLI tool for running tests on Flow types.sharedmemory.heap_size option.Notable bug fixes:
module.exports objects.declare function.type-at-pos.flow suggest no longer outputs <<anonymous class>>.Remote in type-at-pos.Misc:
WeakMap keys must now be objects.preserve_inferred_literal_types is set. This does not change the behavior of type-at-pos.experimental.cancelable_rechecks option.Parser:
expression field from Function nodes in the AST.flow_parser.js which should cause it to stack overflow in fewer cases.{} instead of ; in pretty mode.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:
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.empty, whereas now this is an error.New Features:
_) 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:
get-def and find-refsMisc:
get-def and find-refs to reuse codegetBoundingClient returns a DOMRect instead of a ClientRect.Parser:
... to indicate inexactness in object typesLikely to cause new Flow errors:
Notable bug fixes:
?T) or "optional" (essentially T | void) types{p:T} to be a subtype of $Shape<{+p:T}>Misc:
--verbose to not log while loading flowlibs by default; pass --verbose-flowlibs to overrideLibrary definition changes:
ResizeObserver declarationsnet$Server.listening propertyprocess.cpuUsage()Parser:
export default async function to be a FunctionDeclaration not a FunctionExpressionLikely to cause new Flow errors:
New Features:
--profile mode.Misc:
Likely to cause new Flow errors:
this to appear in a constructor before a super call in some cases.typeof may be reported at a different location than they previously were.require() is not allowed.Notable bug fixes:
Misc:
prototype or constructor.Library definition changes:
scrollIntoView to match latest spec.String.prototype.toLocaleLowerCase and toLocaleUpperCase to allow optional locale parameter.Object.prototype.valueOf return mixed instead of Object.Object libdef.TextDecoder to properly accept a BufferSource.MediaStreamTrackEvent definition.String.match return RegExp$matchResult.fs module.Likely to cause new Flow errors:
// $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.Headers.get and URLSearchParams.get are now annotated to return null | string instead of string and File.lastModifiedDate: any was replaced with File.lastModified: number.Notable bug fixes:
Misc:
BoundT (internal representation of type parameter bounds) smaller.Parser:
extends expression in a class declaration. Moved a couple of properties to their own node.Notable bug fixes:
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:
New Features:
--saved-state-no-fallback is passed in which case Flow fails.name field in the [options] portion of .flowconfig.Notable bug fixes:
flow --json with a large error output, by
moving to a tail-recursive implementation.flow suggest.Misc:
React$Context.Provider and
CanvasRenderingContext2D.imageSmoothingQuality.$Shape.types_js.ml, merge_service.ml, rechecker.ml, etc.).New Features:
unnecessary-invariant lint, which will flag uses of invariant when Flow can determine that the predicate must be truthy.find-refs now traverses union types.--flowconfig-name flag now allows you to specify the name of the flowconfig.file_watcher option for .flowconfig.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 trigger ENOENT on Windows.--profile should no longer throw on Windows.ArrayBuffer's static indexer property is now correctly marked covariant. This should prevent errors like this one.Misc:
Array<T> instead of T[] in JavaScript output.{foo:x} as { foo: x } in JavaScript output, as Prettier does.destroyed to net$Socket.document.scrollingElement.dgram$Socket$rinfo to the Node library definitions.groups property to RegExp$matchResult.New Features:
a && b when a is a number. See https://flow.org/en/docs/linting/rule-reference/#toc-sketchy-numberNotable bug fixes:
Misc:
Context, added readAsBinaryString to FileReaderParser:
Likely to cause new Flow errors:
New Features:
[declarations] section in the .flowconfig which can suppress all errors in 1 or more files. Thanks @LegNeato! (#4916)flow server --file-watcher watchman flag which uses Watchman for file watching instead of the builtin file-watcher, dfind--expand-type-aliases flag to type-at-pos. It replaces type aliases with their bodies in the returned type.flow save-state command to generate a saved state file (experimental & loading a saved state isn't ready yet)Notable bug fixes:
type-at-pos for B in import type { A as B } from 'M';find-refs, autocomplete, get-def, etc for $Facebookism$IdxMisc:
type-at-pos output+ operator to match other binary operatorsLikely to cause new Flow errors:
require call (use import type instead)Array.of stricter (thanks @wchargin!)New Features:
{| |} as a subtype of { +p?: T }[[call]] syntax in objects and interfacesflow find-refs commandNotable bug fixes:
Misc:
--check flag to flow ast commandfilter property to CanvasRenderingContext2D libdeftimingSafeEqual method to node crypto module (thanks @n-johnson!)Parser:
Decorator node, matching estreeLikely to cause new Flow errors:
$ObjMap is used on an exact type).New Features:
Notable bug fixes:
Misc:
ps.max_literal_length option to .flowconfig which replaces a magic constant.find-refs now supports class instances.find-refs on ES6 named exports to improve reliability.react-dom/server libdef.Clients.matchAll to return an Array rather than an Iterator.Parser:
Likely to cause new Flow errors:
New Features:
var foo: interface { x: string } = bar;). Will be particularly useful in the future when we revamp object typesNotable 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 for declare class declarations.Misc:
.mjs to the list of extensions that Flow reads by defaultflow find-refs --multi-hop now parallelizes the work and is much fasterflow find-refs and flow get-def with destructuring patterns as a starting locationflow find-refs with default (as in export default ...) as a starting locationflow find-refs would miss certain locationsflow get-def when used for default and named importsParser:
Likely to cause new Flow errors:
$Exact<empty> as empty. Before, ({p:0}:$Exact<empty>) was not an error due to
missing ground subtyping and decomposition cases. It is now an error.$Either<T>, $All<T> and $Type<T> types are not supported any more.New Features:
multi-hop mode was added that determines when object types are related through subtyping
and links them.Function.prototype.bind as a proto field.* a deprecated type, under the deprecated-type strict flag.--expand-json-output to print an extended JSON output for type-at-pos.onclose to the IDBDatabase interface in lib/indexeddb.js
(reference).onmessageerror to Worker interface and fixed type of MessagePort.onmessage
in lib/bom.js.swap64() to the Buffer type and a Buffer property in lib/node.js.Intl objects for the built-in JS language API (ECMA-402 - Internationalization API).uniform**v setters in lib/dom.js.Notable bug fixes:
Misc:
Object type, "Flow for Atom IDE" in Atom plugins, Flow Strict
and the nonstrict-import lint rule.ocamlbuild).WebGLRenderingContext#is* methods to all return booleans.src/server directory.$Subtype and $Supertype "unclear" types when not in a library context.type-at-pos now prints types at the client-side.Parser:
?? (as above).+ or static inside an object type
(e.g. {+}) are now disallowed.proto modifier in declare class, to specify that the property is
a prototype property instead of a class one.[[new]]).f<T>(x).Likely to cause new Flow errors:
number rather than a literal type. This has been fixed.module and exports. The disallowed patterns include computed property
accesses as well as clobbering or aliasing module and/or exports.
experimental.well_formed_exports=true is specified in
.flowconfig.New Features:
Fragment has been added to the default exports of the React libdef.find-refs on a property key in a type declaration will now also yield that key in
object literals.@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.esproposal.optional_chaining=enable in your .flowconfig.
Notable bug fixes:
estree_translator properly handles all cases of the DeclareClass AST node.suggest command has been fixed to work with the new type normalizer.Misc:
find-refs.Parser:
OptionalMember and OptionalCall nodes instead of the existing
Member and Call nodes, and parentheses now correctly limit the scope of short-circuiting.
This reflects the current Babel implementation.Likely to cause new Flow errors:
Promise libdefs for the cases where null or void is passed as callbacks to then
and catch caused us to miss type errors. These libdefs have now been made stricter.this parameters.typeof with speculative typechecking would lead to missed errors, which will now
be reported as expected.module and exports.API changes:
--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 Features:
createContext and createRef APIs introduced in React
16.3.Notable bug fixes:
Misc:
type-at-pos and friends, including converting normalized types back to
AST nodes for printing.find-refs.Array<T> instead of T[].Parser:
implements and mixins fields of the DeclareClass AST node.tokens option to JS API: flow.parse(..., { tokens: true }) will now return the token
stream, like flow ast --tokens does.Notable bug fixes:
flow status to throw an exceptionMisc:
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:
Notable bug fixes:
Misc:
declare var exports, long deprecatedRestore accidentally-deleted Object.setPrototypeOf library definition.
Likely to cause new Flow errors:
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/>).type-at-pos).Misc:
type-at-pos on method calls that have been affected by type refinements.--profile flag to flow force-recheck.--retry-if-init false.type-at-pos location for opaque type declarations.flow status output when the server is in lazy mode.ReactDOM.hydrate().process.umask's argument optional.Parser:
find-refs from experimental to beta.find-refs performance by 2x-20x depending on the workload.find-refs.find-refs.type-at-pos and coverage thanks to a type "normalizer" rewrite. Notably, the normalizer and client services like type-at-pos now:
any no longer completely resolve to any. This may uncover new bugs in your programs where some inferred types silently resolved to any.({...null}: {p: number}); incorrectly passed Flow. If you were spreading a maybe-object type then Flow may catch some new bugs in your programs.suppress_comment) will become unused since error locations moved.nonstrict-import lint's error message.React.cloneElement for stateless functional components.--max-warnings flag which allows Flow to exit with a non-zero exit code if warnings are present.--file-watcher flag to ignore file system events.url.format's urlObj argument type.Likely to cause new Flow errors:
Improved inference of const bindings (lets and vars 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
}
implements now works on declare class in addition to classdeclare module library definitions are now considered @flow strict@flow strict import rule when in a cycletype-at-pos and coverage commands when they encounter Object.prototype and Function.prototypemerge_timeout .flowconfig option to mirror the --merge-timeout CLI flag added in 0.64implements to DeclareClass nodesLikely to cause new Flow errors:
event is no longer recognized as a pre-declared globalNotable bug fixes:
Performance improvements:
Misc:
Parser:
Bug fix:
flow init, which was generated an invalid .flowconfigLikely to cause new Flow errors:
constdeclare var exports: T is deprecated in favor of declare module.exports: TNotable bug fixes:
any. This avoids cascading internal errors.Misc:
flow get-def (used by IDEs for jump to definition) now behaves differently for variables introduced by an import or require(). 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.Parser:
static in object typesLikely to cause new Flow errors:
unsafe.enable_getters_and_setters option. Getters and setters are now enabled by default. Use the unsafe-getters-setters lint rule to disable.New Features:
flow cycle subcommand, which prints a .dot describing the cycle for a given file.Notable bug fixes:
[lib] files outside the Flow root would not be watched for changesMisc:
nonstrict-import lint rule, which requires that strict files can only depend on other strict files.unsafe-getters-setters lint rule, which replaces the unsafe.enable_getters_and_setters flowconfig option.Parser:
method property to object type property AST node.static for declare class and interfaces.Variance AST node for +/- annotations, matching Babylon.[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.this type is nullable.get-imports command, show every location where a module is imported instead of just one per file.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.
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 of any, Object and Function, since they unsafely circumvent the type system.untyped-import warns when importing or requireing 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 second prop in if (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!
lwt from opamflow coverage in --quiet and --json modes--json consistently imply --quiet in all commands, notably status.log.old fileimport type * a parse error$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!
}
class X {
+p: number;
constructor(p: number) {
this.p = p;
}
}
/* flowlint sketchy-null:error */.React.Element to incorrectly point at
library definitions instead of user code.listen() function.declare class with multiple extends is now a parse error.Likely to cause new Flow errors:
type Foo = { type: 'A', ... } | { type: 'B', ... }`
function match(foo: Foo) {
switch (foo.type) {
case 'C': ... // dead branch, now error! (was allowed previously)
...
}
}
New Features:
@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:
Parser:
Perf:
Reliability:
flow ideMisc:
flow ls--raw type printingNotable bug fixes:
Misc:
Notable bug fixes:
Misc:
Likely to cause new Flow errors:
$Diff's implementation was rewritten. It should behave mostly the same, but will error on $Diff<ObjA, {x: string}> if ObjA doesn't have a property xNew Features:
node_modules/ which are direct or transitive dependencies of the non-node_modules code.Notable bug fixes:
flow ide on Windowsflow server to crash when flow ide exitsimport type * syntax$ObjMap's behavior on optional properties$PropertyType, $Diff, and $ObjMap){[string]: boolean} is no longer a subtype of {(number): string}.Misc:
flow server will now write to a log file in addition to stderrflow ls will now list the .flowconfigflow 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.flow force-recheck --focus which tells a lazy server to start caring about certain filesNew Features:
$Rest<A,B> type, which models the semantics of object restnull prototypes, a la Object.create(null)__proto__ property in object literals and object type annotationsNotable bug fixes:
flow focus-check for multiple filesMisc:
<VERSION> token for suppress_comment option in .flowconfigflow typecheck-contents --graphmlLikely to cause new Flow errors:
$ObjMap.New Features:
mixed into an object type.Notable bug fixes:
Misc:
this types are incompatible.mixed not to be properly printed from type-at-pos.Typedefs:
repl module.Parser:
catch.(switch: number) => void).Notable bug fixes:
Likely to cause new Flow errors:
class A<T> {}; class B extends A {} is now an error, but class C extends A<string> {} or class D<T> extends A<T> {} is ok.Notable Changes:
type T<Phantom> = any; type X = T<string>; type Y = T<number>, where X and Y are incompatible even though T doesn't use Phantom)fs functionsMisc:
type t = T<U>) with empty type args (e.g. var x: T<>)Parser:
flow ast --strict to parse in strict mode without "use strict"({ x = 1 } = {}), x is 1)let, yield, await, async, super and other reserved wordsnew.target and async methodsFixed 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.
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<T>) often with the React element type (Array<React.Element<any>>). However, using arrays is problematic because React children are not always an array. To fix this, now use the new React.ChildrenArray<T> type.
New Features:
Notable bug fixes:
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 typed
currentTarget using that type argument.
Parser:
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 vars that are
only assigned to once as consts, so that we can preserve refinements on them
through longer stretches of code. Some typeof 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:
Notable bug fixes:
class B<+T> extends A<T> {} when A's type parameter is not covariant)New Features:
Notable bug fixes:
Misc:
Parser:
Likely to cause new Flow errors:
New Features:
$Values type.Notable bug fixes:
$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:
Misc:
Parser:
New Features:
flow start or
flow 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, running flow focus-check on a file will only check
that file and files that depend on it (and their dependencies).Notable bug fixes:
Misc:
Likely to cause new Flow errors:
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:
Misc:
any types and continuing typechecking rather than stopping altogether.Parser:
Likely to cause new Flow errors:
React.Component constructor, which means Flow
can now infer the prop types based on the super(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.Promise.prototype.catch, which means code that uses
.catch but wasn't properly handling the exceptional behavior might now have
Flow errorsNew Features:
.flowconfig option experimental.strict_call_arity=true. For more check out this blog postNotable bug fixes:
undefined to unfulfilled parameters.declare class classes would be given a default constructor even if they extended another classMisc:
--no-suppressions with --include-suppressed which is a little bit more well-behaved.--pretty flag to flow check for pretty-printed JSONParser:
declare function declarations with predicatesyield expressions with semicolonsdeclare module declarations[a=1, b] = c was parsed like [a=(1, b)] = c.New Features:
import expressions (Thanks deecewan!)export type * from ..., an analogue of export * from ...Notable bug fixes:
Misc:
Parser:
Notable bug fixes:
HTMLBRElement, which extended itself :(New Features:
Notable bug fixes:
Misc:
Features:
Parser:
Notable bug fixes:
Misc:
Likely to cause new Flow errors:
New Features:
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.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:
Parser:
Misc:
React.PropTypes.oneOf must take an array of literals. You can now put non-literal values in the array.Notable bug fixes:
React.createClass components (including mixed in proptypes). This has been fix and may uncover new proptypes errors in createClass componentsfindDOMNode has been updated to include null in its return-type now (since this function can, indeed, return null)Misc:
flow get-importers has been removed. It was rarely used and added an incredible amount of complexity to the codebaseNotable bug fixes:
React.createClass() even when they were not needed.this and super in class method parameter defaults.Parser:
Misc:
Likely to cause new Flow errors:
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)New Features:
--no-suppressions to flow check in order to see what errors would show up in your codebase if you deleted all the error suppressions$Flow$DebugPrint type to make Flow print a JSON representation of a type. Example usage: declare var flowDebug: $Flow$DebugPrint; flowDebug(someVariable);Notable bug fixes:
yield expressionFunction.prototype.bind() wasn't working properly on variables typed as "callable objects" in Flowimplements could cause a "Did not expect BoundT" errorTERM environment variable wasn't set (Thanks @SamirTalwar!)Parser:
+ tokens in object types (like it already did for object literals)"use strict")Misc:
Likely to cause new Flow errors:
// $FlowFixMe (or any kind of suppress_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.New Features:
implements - classes can now implement one or more interfaces and Flow will verify that the class properly implements the interfaces.flow find-refs file line column - if there is a variable x at file:line:column, then this command returns the location of x's definition and the location of all reads and writes to x.import {someValue, type someType, typeof someOtherValue} from 'foo'$ReadOnlyArray<T> is the common supertype of arrays and tuples. It's basically an array without stuff like push(), pop(), etcdeclare class, interface's, object types, etc. They're still not safely checked, though.emoji=true in the .flowconfig options and flow status will put emoji in the connection status messages (thanks @zertosh!)Notable bug fixes:
require(), (e.g. require(`foo`))Object.keys no longer returns methods since they are not enumerableT had the type Array<T>. Now it's Array<*>, which lets you add elements of other types to the array.$Shape to ignore "shadow properties", which are properties that don't really exist, but which have been referenced somewhere.unsafe.enable_getters_and_setters=falseMisc:
make no longer complains if js_of_ocaml is not installedflow check --profile now includes CPU timeflow server --profile and flow start --profile now print profiling info to the logstests/ which run a flow server now save the .log file when they fail--no-flowlib, which make them much fasterParser:
kind of a static method named constructor to be "method" rather than "constructor"import type shorthandNotable bug fixes:
Notable bug fixes:
Notable bug fixes:
Notable bug fixes:
Likely to cause new Flow errors:
// $FlowFixMe (or any kind of suppress_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:
import type/import typeof inside the body of a declare module to import types between libdefs.Notable bug fixes:
any + number would yield number. Now it correctly yields any.flow check-contents where input is provided via stdin.Misc:
--old-output-format CLI flag is now gone.parse() function in the flow-parser NPM module now takes either 1 or 2 arguments. Previously it would require both arguments in order to work.Likely to cause new Flow errors:
New Features:
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 under dirA/, files under dirB/, and file.jsNotable bug fixes:
obj['method']()) is now supported--strip-root set now show context againMisc:
flow coverage and flow 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.let x = x;Parser:
[...rest, 123] was incorrectly parsedLikely to cause new Flow errors:
addEventListener() with 'click' and 'dblclick' will pass a MouseEvent to the listener. This means you might need to update foo.addEventListener('click', (e) => bar()) to foo.addEventListener('click', (e: MouseEvent) => bar()).New Features:
Notable bug fixes:
Misc:
foo has the typed mixed, we now allow foo.bar if you check that foo is not null or undefined.Parser:
let statements, which never made it into the spec (thanks @andreypopp)Likely to cause new Flow errors:
{[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 using Map/Set/etc. Please see this blog post for more information on variance.type T = {+covariantProp: string}. Please see this blog post for more information on variance.type T = {covariantMethod(): string} is the same as type T = {+covariantMethod: () => string}. Please see this blog post for more information on variance.New features:
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).--quiet flag to suppress server-status information that would otherwise be printed to stderr.React.createElement. See the commit message for more details.for-await-of statements.Notable bug fixes:
get-def and autocomplete 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-unfinished IteratorResult object rather than a definitely-done iterator result. See #2589 for more details.munge_underscores config option is set to true.Misc:
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.Parser breaking changes:
ExportNamedDeclaration and ExportDefaultDeclaration nodes from ESTree rather than the outdated ExportDeclaration node.export default class {} now correctly emits a ClassDeclaration rather than ClassExpression per this estree issue.ExportSpecifier property names from id -> local and name -> exported per the latest ESTree spec.ExportBatchSpecifier to a ExportNamespaceSpecifier node per the latest ESTree spec.SpreadElementPattern -> RestElement per the latest ESTree spec.ObjectPattern are now named Property and RestProperty per the latest ESTree spec.Super node now instead of an Identifier node per the latest ESTree spec.{ImportNamedSpecifier and ImportDefaultSpecifier nodes now use proper local and remote property names, per the latest ESTree spec.mixed type annotation is now represented with a special MixedTypeAnnotation node (same as Babylon has been for a while).NullTypeAnnotation annotation node is now called NullLiteralTypeAnnotation in order to match Babylon.Likely to cause new Flow errors:
mixed to numberNew features:
suppress_comment now defaults to matching // $FlowFixMe if there are no suppress_comments listed in a .flowconfigpackage.json file is changedPromise.all() (thanks @vkurchatkin!)Notable bug fixes:
Function.prototype and Object.prototypeflow get-def wouldn't hop to the location of a type coming through an import typeany-typed variable as a computed-property lookup results in the wrong property-value typethrows at the toplevel of a module[libs] with an extension not listed in module.file_exts, it would previously be silently ignoredimport * as on a declare module.exports: any; libdef would not result in a module with every possible named export"JSX attributes must only be assigned a non-empty expression" syntax errors sometimes point to the wrong lineget or set in object short notationx = { async 123() { await y; } }u regex flagMisc:
new.target--pretty flag to all commands that have a --json flagflow coverage when --json is passed (thanks @aackerman!)Parser breaking changes:
SwitchStatementguardedHandlers from TryStatementAssignmentPattern for function param defaults to match ESTreeRestElement for function rest params to match ESTreeExpressionStatementCallExpression and MemberExpressionNotable bug fixes:
Likely to cause new Flow errors:
obj has a property foo that Flow doesn't know about, Flow will now refine obj.foo to the type mixed. If you then try to use obj.foo in an unsafe way (like as a function), you might start seeing errors mentioning property `foo` of unknown type. The fix is to either fix the type of obj to include an optional property foo, or to rewrite code like obj.foo && obj.foo(x) to typeof obj.foo === "function" && obj.foo(x)Array.prototype.find to reflect the fact that it can return undefinedNew Features:
{| and |} instead of { and }. Where {x: string} contains at least the property x, {| x: string |} contains ONLY the property x..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 a string (except for .css files, for which you get an Object). You should still be able to use module.name_mapper to map a resource file to a mock, if you prefer.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:
any, then the types it exported were also given type anyflow coverage had a non-termination bug. This is now fixed.Misc:
Likely to cause new Flow errors:
any type could actually prevent errors from showing up in places that actually should surface errorsArray.isArray() now refines arrays to Array<mixed> instead of Array<any>New Features:
munge_underscores option is set, Flow no longer requires annotations on exported classes with munged methods. (thanks @pvolok!)$PropertyType<T, 'x'>. This utility extracts the type of the property 'x' off of the type T.| and & on any type annotation, not just in type aliasesNotable bug fixes:
flow start would sometimes hang on Windowsflow get-def on a react element would always point to the internal react libdef (rather than the component that defines the element)Promise.resolve(undefined) would not always error as it shouldflow coverage when reporting coverage on empty files... will be printed as an overflow placeholderLikely to cause new Flow errors:
React.PureComponent's definition, so previously missed errors are now reportedconsole in the build-in libdef has been filled out and is no longer any.New Features:
Class<T>. So if class B extends class A, then Class<B> is now a subtype of Class<A>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:
--trace behavior when we unify typesFunction.prototype.{apply,call}flow stopMisc:
undefined is now just a global variable declared in the libdefsnullableArr.filter(Boolean) is non-nullableNew features:
Notable bug fixes:
string argument and one overload that handles a number overload, then passing in a union string | number should now work.import {type} from "Foo"experimental.strict_type_args=false and type parameter upper bounds.Misc:
flow check --json --profile now includes profiling info in the JSON
responseLikely to cause new Flow errors:
+. This may surface template strings with variables that may not safely coerce to a string.any -- but now this must be explicit. This behavior is toggleable via experimental.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:
declare export within declare module bodies. When declare export is used, the module being declared is inferred as an ES module. This enables the ability to export both named and default exports using declare module.Notable bug fixes:
Misc:
@flow in all comments at the top of the file (rather than just the first). It's also possible to configure this using a new max_header_tokens .flowconfig option.flow coverage commandNotable bug fixes:
--strip-root is now applied to the output of --verbose(@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:
New Features:
**)flow ls command to list the files that Flow can see.Notable bug fixes:
/x/* 5 */y/ - that's no comment!Misc:
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 writing my_function was the same thing as writing my_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, like type Foo<T = number>, you can now write Foo<> to apply 0 type arguments to the polymorphic type Foo.
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 write declare var exports: type;. This can be used in .flow files and in declare module declarations.Misc:
autocomplete can show internal variable names for files that use destructuringNew features:
<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!)type Iterator<Yield, Return=void, Next=void> = ....
Notable bug fixes:
flow coverage command.type-at-pos and dump-types over destructuring.void could end up as exactly void (rather than a union of the possible return types)..json file is deleted after a server was already running.Map<number>) now emit a more clear error.Misc:
.json files by name coalesced with .js filesLikely to cause new Flow errors:
mixed variable with typeof myVar === 'object', we used to refine the type of myVar to null | Object. Now it is refined to null | {[key: string]: mixed}. This means myVar.prop has the type mixed rather than any.New features:
flow init now has more command line flags to specify what should be in the created .flowconfigflow ast now can parse JSON files.flowconfig files. Lines starting with # or ; are ignored[ignore] section of a .flowconfig you can now ignore a relative path with <PROJECT_ROOT>/path/to/ignoredflow commands have an --ignore-version flag to skip the version check specified in the .flowconfig.module.use_strict option to the .flowconfig. When it is true, Flow will treat every file as if it has the "use strict"; directive.number type into number literal types. (e.g. after x === 0 Flow now knows that x has the type 0)flow force-recheck FILE1 FILE2 command tells the flow server that FILE1 and FILE2 have changed and that it should recheck. This is intended for tooling that might be racing the file system notifications.!x evaluates to for various types of x.<Foo /> is now allowed when Foo is a string. If $JSXIntrinsics is defined, Foo must be a subtype of $Keys<$JSXIntrinsics>esproposal.decorators config option). Thanks @marudor!Notable bug fixes:
(obj: SomeClass) except for when obj instanceof SomeClass.flowconfigall flag to the .flowconfig--strip-root flag for displaying errorsasyncif (foo[0]) { ... }, which should work like if (foo["prop"]) { ... } does. That is, Flow should remember that foo[0] exists and is truthy.Misc:
flow start --json will start a server and output a JSON blob with info about the new serverObject.values() and Object.entries return Array<mixed> and Array<[string, mixed]> respectively, since Flow currently is never sure that it knows about every property in an object.Likely to cause new Flow errors:
New features:
node_modules dependency in the [ignore] section of your .flowconfig if you have a library definition defined for that dependency.Promise.all: We now preserve the type of each item in the array passed to Promise.all() so that it may be propagated through to the resulting .then() handler.@flow pragma. We anticipate this will improve performance for projects with large, non-Flow node_modules directories.| 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:
obj['abc'] didn't behave quite the same as refining obj.abcflow get-def on the left-hand side of a require() wouldn't hop through the require() and to the actual location of the definitionimport type to get a non-type exportflow dump-types --json was not as robust as it could be against outputting valid JSON in the event of certain kinds of errorsdeclare class declarations now properly define a built-in name property (like real class declarations do)Likely to cause new Flow errors:
extends React.Component<DefaultProps, Props, void> (previously it was extends React.Component<DefaultProps, Props, {}>)state: State;if (o.noSuchP === foo) { ... }). These kinds of checks will now cause a type error.New features:
div, span, etc) and specify which properties they have.interface Generator<+Yield,+Return,-Next> {...}. Still pending transpiler support though.string and union types with string equality now properly refines the types.export * as from @leebyron's Stage1 proposal. Babel support hereNotable bug fixes:
this typethisswitch statements with default case.Misc:
Bug fixes:
this typeMisc:
New features:
this return type for class methodsimport typeof * as now allows for concise access to the type of the ModuleNamespace objectrequire()/import a .json fileBug fixes:
declare type wouldn't work in a declare module that has an exports entryFunction.prototype.bind would lose the types of the params on the function it outputmodule.file_ext would cause internal flow libs to be ignoredFunction typesexport * from (it should work fully now)Misc:
Function.prototype.{bind,call,apply}import statements where the remote exports don't exist (or may be typo'd)let variablesflow get-def will now hop through lvalues in variable assignments for more fine-grained "hop-tracing" of a variable back to its definitioncallable signature can now be passed in to type positions that expect a function with a matching signatureLikely to cause new Flow errors:
@flow files. Use @noflow to work around thisimport type * as Foo is now disallowed in favor of import type Foorequire() can only take a string literalextends React.Component<void, Props, State> (previously it was extends React.Component<{}, Props, State>)static defaultProps: DefaultProps;React.createClass() react componentsin keywordNew Features:
flow coverage commandnull type annotation.flowconfig optionsfoo.js and foo.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 fileNotable Bug Fixes:
Misc:
--root arg to most client commandsflow get-def: Jump to module named in import statementvar {x} = new Foo()flow server will write to log file in addition to stdout/stderrLikely to cause new Flow errors:
null works when used as an initialization value for object properties that are mutated later. So let o = {prop: null}; o.prop = 42; is now an error and requires that null be annotated: let o = {prop: (null: ?number)};.New Features:
const variables are read-only when doing refinements. This means that refinements of const variables now have much fewer caveats than refinements of lets or vars. For instance, it's safe to depend on the refined type of a const within a local function created in scope of the refinement, even if the function escapes.esproposal.class_static_fields=warn|ignore and esproposal.class_instance_fields=warn|ignore. This allows the new ES class fields syntax to be ignored.module.system.node.resolve_dirname. This allows configuration of the name of the node_modules directory (or directories) used by the node module system. This is similar in behavior to webpack's resolve.moduleDirectories config option.<PROJECT_ROOT> token in the template string for the module.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:
yield without an argument.Misc:
flow single as it is effectively redundant with flow check --max-workers=1.flow --version is now deprecated in favor of flow version.New Features:
Notable Bug Fixes:
make on OSX now works when lib/ files changereturn() and throw() methods are now supporteddefault using named specifiers is now supportedFlow now understands this in class static methods and this.constructor in class instance methods (thanks @popham!)name propertyMisc:
flow find-moduleObject can now be called as a function to cast things to objectsLikely to cause new Flow errors:
New Features:
mixins on declare class library definitionsNotable Bug Fixes:
Misc:
--traces outputLikely to cause new Flow errors:
this before super() in a derived constructor, per ES6 semanticsinterfaces and declare class. Now we are.New Features:
if(x.y[a.b])export type {type1, type2} syntaxNotable Bug Fixes:
T or a Promise<T> and it means the same thingMisc:
Likely to cause new Flow errors:
?string and you assign 'hello' to it, Flow refines its type to 'string'.Likely to fix old Flow errors:
any. For example, previously ReactElement was treated as ReactElement<*, *, *>. Now it's treated as ReactElement<any, any, any>.Misc:
unsafe.enable_getters_and_settersdeclare type in lib filesLikely to cause new Flow errors:
+ and += to only allow strings and numbers, and no longer implicitly cast objects, booleans, null or undefined. Use String(x) to explicitly cast these values.Misc:
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 intermediate MyThing_tmp variable)flow ast command to print a serialized JSON ESTree AST. (Note that this AST does not include types, just syntactic structure for now)export type within a CommonJS module that also uses the module.exports = ... patternundefined to optional parametersLikely to cause new Flow errors:
A.foo() returns a Promise, and module B requires A and calls A.foo(), the return type of A.foo() was not being checked properly)Object<K, V> errorsnull and undefined)New features:
for-of and support for Iterable interface(s)async/awaittypeof x, where x is the name of an in-scope variablesuppress_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.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--color=always|never|auto CLI option, useful when piping to less -R--one-line CLI option which replaces \n with \\n in multiline error messages, useful when piping to grepMisc:
export default classif (x instanceof Array)x && y when x is an array, object or functionflow get-def command, especially around imported types== and improved comparison-related error messageslog.file which overrides the default log file pathany to workaround things that you want to fix later? Well, now you can use $FixMe instead of any and easily grep for these workarounds later.require()'ing/import'ingflow check --traces N, where N is the trace depthObject.freeze()for_type valuex != undefined and x != null as the same refinement** Flow comments should be ready for use **
** Type casts and import type should be ready for use **
delete method signaturesInitial release