Local Type Inference:
We are releasing a new inference mode called local type inference. You can enable this new mode in your codebase by adding inference_mode=lti to the [options] section in the flowconfig. We will describe more details on this inference mode in an upcoming blog post.
Likely to cause new Flow errors:
- Unannotated class properties initialized with null will now errors.
- We now require all generic functions to be fully annotated.
boolis a deprecated alias forboolean. Added adeprecated-type-boollint andflow fix --error-codes deprecated-typecodemod to help migrate toboolean. This lint is also included in thedeprecated-typelint; ifdeprecated-typeis enabled, you can opt out withdeprecated-type-bool=off
New Features:
- Tuple improvements:
$ReadOnlyutility makes tuples read-only. E.g.$ReadOnly<[string, number]>is the same as[+a: string, +b: number].- Tuple elements can now have their variance annotated, when the element is labeled. E.g.
type T = [+foo: number, +bar: string]creates a read-only tuple. - You can now label tuple elements (like TypeScript allows). The labels have no type-checking effect, they just help with self documentation (like indexer labels). When a function argument rest element is a tuple type, the labels work like parameter names in signature help.
- We now parse tuple spread elements, but type checking of this feature is still unsupported.
- These new features are now supported in Flow, but we have not upgraded related tools yet. For example, Prettier won't be able to format your code that uses variance annotations on tuples.
- Allow
mixedoranyas an annotation to acatchparameter (but not anything else) - When typing in a class body, method signatures from super classes and interfaces will be suggested to make overriding/implementing these methods easier.
Notable bug fixes:
- Improve the parser's error recovery when in the middle of adding type parameters.
- Trigger autocomplete in JSX tags, JSX attribute values, and private class fields.
- Improves performance of bigints in big union checks
Misc:
- Inferred recursive types are shown as
any(instead ofV$n) in hover types.
Parser:
symbolis now a reserved typefor (async of [])is now a parse error
Library Definitions:
- Updated
AbortControllerandAbortSignalsignatures - Actually expose
ReactSetStateFunctiontype introduced in the last release.