Releases: facebook/flow
Releases · facebook/flow
v0.278.0
Likely to cause new Flow errors:
- Hooks calls inside normal functions in component or hooks as conditional calls. They will get
react-rule-hook-conditional
error instead ofreact-rule-hook
error. - Array literals that cannot be contextually typed will be inferred as an actual array type. It might cause additional errors. example
v0.277.1
Notable bug fixes:
- Fixed windows builds.
v0.277.0
v0.276.0
Likely to cause new Flow errors:
- Hook calls inside anonynous functions bound to a variable will get
react-rule-hook-definitely-not-in-component-or-hook
error, if the variable name doesn't conform to hook naming convention. example
IDE:
- Added support for workspace symbol feature
Misc:
- Thanks @jbroma for improving
as
casts withfunction
generics andcomponent
generics!
v0.275.0
Likely to cause new Flow errors:
- For all object literals in positions that cannot be contextually typed, we will infer a stricter type for them. It will cause new errors in code like
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:
- Support rename on private properties and methods.
Library Definitions:
React$MixedElement
is removed from builtin libdef. It will causeinternal-type
error sincev0.258.0
. You should useReact.MixedElement
instead.
v0.274.2
- Bug fixes for
match
v0.274.1
New Features:
- Support for experimental
match
feature using optionexperimental.pattern_matching=true
v0.274.0
Likely to cause new Flow errors:
- Unannotated object literals reachable from exports will now be inferred to have all mutable fields when being imported. Previously, it has unsound types, so new errors might appear.
- When comparing two object types whose properties have variance incompatibilities, Flow will raise a single error that will summarize the properties with incompatible variances, instead of a single error for each property. (e.g. try-Flow)
- When an object with extra properties is passed to a place that expect an exact object, we will now generate a single error with all extra properties. The error message will list the extra properties, and state that "Exact objects do not accept extra props". In rare cases, the error locations might be moved.
- Flow will error more consistently with sketchy-bool on nullable boolean types (e.g. try-Flow)
Library Definitions:
- All properties in the builtin
PropertyDescriptor
type are marked as readonly. If you need a mutable version, you can introduce something liketype MutablePropertyDescriptor<T> = {...$Exact<PropertyDescriptor<T>>, ...}
v0.273.1
Notable bug fixes:
- Fixed windows builds.
- Fixed crash when loading saved state.
v0.273.0
Likely to cause new Flow errors:
- We are announcing Natural Inference for Flow, an improved way to infer types for primitive values, that resolves a long-standing correctness gap and source of confusion. See more in this post.
- Added
nested-hook
andnested-component
lint errors which detect nested hook or component syntax within component or hook syntax. This is on by default.
Notable bug fixes:
- For default imports, the autoimport ranking will now consider the names of the importing side. (e.g. Previously we completely ignored the name of
foo
inimport foo from './bar'
, but now we will count foo. If the pattern ofimport foo from './bar'
happens a lot, then the autoimport algorithm will be more likely to suggestimport foo from './bar'
rather thanimport bar from './bar'
). - Flow will infer a correct type when viewing the type of an object literal as a dictionary type. For example, the error in this try-Flow will be raised.
- Previously, we undercounted some imports during indexing, which causes autoimport ranking to behave incorrectly. The issue is now fixed.
- Flow will no longer emit
react-rule-hook-conditional
error for hooks called in a conditionally defined nested component.