v0.34.0
Likely to cause new Flow errors:
- Dictionary types (i.e.
{[key: string]: ValueType}
) were previously covariant which proved to be a significant source of unsoundness. Dictionary types are now invariant by default in order to fall into consistency with other collection types. It is possible to opt in to explicit covariance with new syntax:{+[key: string]: ValueType}
, but note that this is now enforced covariance -- which means the dictionary can no longer be written into (only read from). For mutable collections, consider usingMap
/Set
/etc. Please see this blog post for more information on variance. - Object property types are now invariant by default. New syntax allows explicit opt-in to enforced covariance:
type T = {+covariantProp: string}
. Please see this blog post for more information on variance. - Object method types are now covariant by default. So this:
type T = {covariantMethod(): string}
is the same astype T = {+covariantMethod: () => string}
. Please see this blog post for more information on variance.
New features:
- New
empty
type annotation. This is the "bottom type" which is the type that has no possible values. This is mostly useful for asserting impossible types right now (see the commit description for more details). - All server commands now have a
--quiet
flag to suppress server-status information that would otherwise be printed to stderr. - It's now possible to specify an "@jsx" pragma to override the implicit default of
React.createElement
. See the commit message for more details. - async iteration is now Stage 3, so Flow now supports async generators and
for-await-of
statements.
Notable bug fixes:
- Calling
get-def
andautocomplete
on specifiers in import statements now works properly and links in to where the specifier is exported in the other file. Generator.prototype.return
now returns a possibly-unfinishedIteratorResult
object rather than a definitely-done iterator result. See #2589 for more details.- Fixed an issue with inferring the proper return-type of iterators coming from a generator with multiple return-types. See #2475 for more details.
- Fixed an issue where a non-polymorphic class-instance used as a CommonJS export wasn't omitting underscore-prefixed members when the
munge_underscores
config option is set totrue
. - Fixed an issue where Flow would previously not consider non-@flow files when re-calculating type dependencies on a change to the filesystem. This caused sporadic issues where Flow might think that a module is missing that actually is not! This is now fixed.
Misc:
- Significant memory usage optimizations by normalizing common aspects of the many "reason" structures stored in memory to use ocaml variants.
- Significant memory usage optimization by compressing the contents of the shared heap used by the persistent server.
- Parser now allows for duplicate properties and accessors in objects per the latest ES spec.
- Flow parser is now tested against esprima3 tests
yield
expressions no longer evaluate to an optional type. This is unsound, but the inconvenience was so prevalent that we decided to relax the issue for now. See #2080 for more details.- Various core libdef updates.
Parser breaking changes:
- Updated the parser to use the latest
ExportNamedDeclaration
andExportDefaultDeclaration
nodes from ESTree rather than the outdatedExportDeclaration
node. export default class {}
now correctly emits aClassDeclaration
rather thanClassExpression
per this estree issue.- Updated
ExportSpecifier
property names fromid
->local
andname
->exported
per the latest ESTree spec. - Update
ExportBatchSpecifier
to aExportNamespaceSpecifier
node per the latest ESTree spec. - Renamed
SpreadElementPattern
->RestElement
per the latest ESTree spec. - Node-properties of
ObjectPattern
are now namedProperty
andRestProperty
per the latest ESTree spec. - Use a
Super
node now instead of anIdentifier
node per the latest ESTree spec. {ImportNamedSpecifier
andImportDefaultSpecifier
nodes now use properlocal
andremote
property names, per the latest ESTree spec.- The
mixed
type annotation is now represented with a specialMixedTypeAnnotation
node (same as Babylon has been for a while). - The
NullTypeAnnotation
annotation node is now calledNullLiteralTypeAnnotation
in order to match Babylon.