Adds static typing to JavaScript to improve developer productivity and code quality.
MIT License
Bot releases are visible (Hide)
Published by flow-bot almost 8 years ago
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.Published by about 8 years ago
Likely to cause new Flow errors:
mixed
to number
New 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.prototype
flow get-def
wouldn't hop to the location of a type coming through an import type
any
-typed variable as a computed-property lookup results in the wrong property-value typethrow
s 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:
SwitchStatement
guardedHandlers
from TryStatement
AssignmentPattern
for function param defaults to match ESTreeRestElement
for function rest params to match ESTreeExpressionStatement
CallExpression
and MemberExpression
Published by about 8 years ago
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 undefined
New 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 any
flow coverage
had a non-termination bug. This is now fixed.Misc:
Published by about 8 years ago
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 placeholderPublished by about 8 years ago
Likely 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 stop
Misc:
undefined
is now just a global variable declared in the libdefsnullableArr.filter(Boolean)
is non-nullablePublished by over 8 years ago
New 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 responsePublished by over 8 years ago
Likely 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
commandPublished by over 8 years ago
Notable bug fixes:
--strip-root
is now applied to the output of --verbose
Published by over 8 years ago
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:
Published by over 8 years ago
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.26.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:
flow ls
command to list the files that Flow can see.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.Notable bug fixes:
/x/* 5 */y/
- that's no comment!Misc:
New 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
filesPublished by gabelevi over 8 years ago
Likely 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 .flowconfig
flow 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/ignored
flow
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
.flowconfig
all
flag to the .flowconfig
--strip-root
flag for displaying errorsasync
if (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.Published by jeffmo over 8 years ago
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.abc
flow 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)Published by gabelevi over 8 years ago
Likely to cause new Flow errors:
extends React.Component<DefaultProps, Props, void>
(previously it was extends React.Component<DefaultProps, Props, {}>)
state: State;
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 here
Notable bug fixes:
this
typethis
switch
statements with default
case.Misc:
Published by gabelevi almost 9 years ago
Bug fixes:
this
typeMisc:
Published by jeffmo almost 9 years ago
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 signature