Adds static typing to JavaScript to improve developer productivity and code quality.
MIT License
Bot releases are visible (Hide)
Published by facebook-github-bot almost 7 years ago
Published by facebook-github-bot almost 7 years ago
Fixed a bug introduced in 0.60.0 in which Flow would not start if its temp directory did not exist.
Published by facebook-github-bot almost 7 years ago
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 import
ing or require
ing a module that does not have @flow
.Made the union created by $Values
on a frozen object maintain singleton literals. That makes this pattern work:
const Enum = Object.freeze({
X: 'x',
Y: 'y',
});
type EnumT = $Values<typeof Enum>
('a': EnumT); // now errors. previously, EnumT was any string
Fixed Object.keys
and $Keys
on a dictionary of string literal keys, such that the result is now an array of the string literals instead of a generic string:
function f(dict: {['hi']: mixed}) {
(Object.keys(dict): Array<'hi'>);
(Object.keys(dict): Array<'bye'>); // error
}
Simplified the types mentioned in some error messages, like from "type application of polymorphic type: class type: Foo" to just "Foo"
Fixed get-def
locations on class and object properties
Fixed get-def
on refined object properties like the 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 errorPublished by facebook-github-bot almost 7 years ago
$ReadOnly<T>
utility type which makes all properties on objects$ReadOnly<{ a: number, b: string }>
behaves as if you wrote{ +a: number, +b: string }
. Read more about property variance ontype 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 atlisten()
function.declare class
with multiple extends is now a parse error.Published by facebook-github-bot almost 7 years ago
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[strict]
section of .flowconfig
. Here are theError reporting:
Parser:
Perf:
Reliability:
flow ide
Misc:
flow ls
--raw
type printingNotable 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 x
New 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 .flowconfig
flow ls
will now list lib files, even if --all
is not setflow ls --imaginary
will list nonexistent files. It's useful for speculating whether or not Flow would care about a file if it existed.flow force-recheck --focus
which tells a lazy server to start caring about certain filesPublished by facebook-github-bot about 7 years ago
New 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 .flowconfig
flow typecheck-contents --graphml
Published by facebook-github-bot about 7 years ago
Likely 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
).Published by facebook-github-bot about 7 years ago
Notable bug fixes:
Published by facebook-github-bot about 7 years ago
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 methodsPublished by facebook-github-bot about 7 years ago
Fixed a bug that sometimes crashed the server during recheck
Published by facebook-github-bot about 7 years ago
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 var
s that are
only assigned to once as const
s, 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!
Published by facebook-github-bot about 7 years ago
New Features:
Notable bug fixes:
class B<+T> extends A<T> {}
when A
's type parameter is not covariant)Published by facebook-github-bot about 7 years ago
Published by facebook-github-bot over 7 years ago
New Features:
Notable bug fixes:
Misc:
Parser:
Published by facebook-github-bot over 7 years ago
Likely to cause new Flow errors:
New Features:
$Values
type.Notable bug fixes:
$ReadOnlyArray
covariant in variance checking.Published by flow-bot over 7 years ago
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.
Published by flow-bot over 7 years ago
Notable bug fixes:
Misc:
Parser: