Releases: facebook/flow
Releases · facebook/flow
v0.254.0
Likely to cause new Flow errors:
- Previously we incorrectly applied truthy refinement on optional chaining where it shouldn't be applied. The issue is now fixed, and you might see change in behavior similar to these examples
Library Definitions:
- Improve Array
toSpliced
method type (thanks @aph!)
v0.253.0
Likely to cause new Flow errors:
React$ElementRef
is now implemented with a conditional type instead of a builtin Flow utility type. You might see new errors with genericReact$ElementRef
. Most of the times, you should replaceReact.ElementRef<T>
with justT
if there are no other uses of genericT
.- We've increased safety in checks involving recursive types.
New Features:
- You can now set multiple
@flowtyped
like directories viamodule.declaration_dirnames
config. e.g.
module.declaration_dirnames=<PROJECT_ROOT>/decl1
module.declaration_dirnames=<PROJECT_ROOT>/decl2
Please note that when you set this, @flowtyped
at the root will no longer be considered special, and you will need to explicitly add it like
module.declaration_dirnames=<PROJECT_ROOT>/@flowtyped
Notable bug fixes:
- A generic type as input to conditional type will have type parameters pinned with their default or upper bound, instead of being
empty
. - We fixed a cache collision issue that might cause instantiation of a value-imported generic component type to interfere with a typeof-imported generic component type.
IDE:
- Flow now respects
includeDeclaration
from LSP request for find-references command. In practice, this means that "find all references" in vscode will continue to return both declaration and all uses, while "go to references" will exclude the declaration.
v0.252.0
Likely to cause new Flow errors:
- Flow will no longer apply type transformation to function components' props when you extract props through the utility types. For example, function components' props won't automatically get
$ReadOnly
applied, which might cause new errors.
New Features:
- We have removed the restriction of not allowing generics with ref prop in component syntax
Notable bug fixes:
- Files in
[declarations]
section will have all lint errors silenced. - Fixed an issue that caused errors in hover type on unions of evaluated types (example)
- Flow allows unions of strings to be used as the key in creation of objects with computed properties.
v0.251.1
Misc:
- Performance fix
v0.251.0
Likely to cause new Flow errors:
- Remove the deprecated
React.AbstractComponent
type. We recommend replacing them with component types. Since v0.249.0, we have provided a codemod via theflow-upgrade
package to aid larger codebases with this conversion:yarn run flow-codemod eliminateAbstractComponent path/to/src
. - In addition to the removal of
React.AbstractComponent
type, we also removed support for the internalReact$AbstractComponent
when more than 1 type argument has been passed. Similarly, you should migrate to use component types if you want to specify ref props and renders.
New Features:
- We now support a new way to easily specify library definitions for npm modules. For all files in
@flowtyped
directory at the root, they can be resolved by the relative path without leading./
relative to@flowtyped
. e.g.<PROJECT_ROOT>/@flowtyped/react.js.flow
can be used to type thereact
package, and<PROJECT_ROOT>/@flowtyped/react/jsx-runtime.js.flow
can be used to typereact/jsx-runtime
module. We now recommend using this approach instead of usingdeclare module
in global libdef.
Notable bug fixes:
any
will now correctly propagate to inferred render type. example.- Fixed a bug with regard to jsx type inference with generic callable objects. example
- Fixed a soundness hole that allowed frozen objects to be incompatible with non-readonly objects. This example will now produce an error.
Library Definitions:
- We have updated some core React type definitions to use the new component type instead of
React.AbstractComponent
. Most of the code won't be affected, but you might have to sometimes make the Props readonly.
v0.250.0
Likely to cause new Flow errors:
- Fix a bug where scope analysis of exported component type is done incorrectly, which causes generics mentioned within component type to be incorrectly typed as any.
Notable bug fixes:
- We will now remove previous props in generic component types in type argument inference. example
- When
all
option is specified in the config offlow-remove-types
, we now respect it and will correctly handle Flow-typed files without@flow
pragma.
v0.249.0
Likely to cause new Flow errors:
- Uses of
React$AbstractComponent
outside library definitions will now triggerinternal-type
lint error, which is on by default.React.AbstractComponent
is also marked as deprecated. We recommend replacing them with component types. We have provided a codemod via theflow-upgrade
package to aid larger codebases with this conversion:yarn run flow-codemod eliminateAbstractComponent path/to/src
.
Notable bug fixes:
- Fixed issue with
StringPrefix
andStringSuffix
when used as a component syntax prop. - Fixed an issue that causes type argument inference on component type to be incorrectly under-constrained. (example)
- Fixed
as
cast support inflow-remove-types
.
Library Definitions:
- React string refs are no longer supported in
React.cloneElement
. e.g.React.cloneElement(e, {ref: 'foo'})
will be an error. - The deprecated
React$Ref
type and various aliases of it are removed.
v0.248.1
IDE:
React.Component
annotated exported will now also show up in auto-imports in a type position.
v0.248.0
Breaking changes:
- Support for long deprecated predicate function (
%checks
) is removed. It will still parse, but all of them will error with unsupported-syntax, and%checks
will be completely ignored for type checking purpose as if it doesn't exist. $TupleMap
support is now removed.$TupleMap
will now resolve to the global definition is there is one, or it will fail and the type becomes any.
Likely to cause new Flow errors:
- Support for the unsound
$TEMPORARY$*
types is dropped. If your codebase happens to have any of these types, you can replace them with there sound and well-documented equivalents:- Replace
$TEMPORARY$object<{props}>
with$ReadOnly<{props}>
or{props}
- Replace
$TEMPORARY$array<T>
with$ReadOnlyArray<T>
orArray<T>
- Replace
$TEMPORARY$number<42>
withnumber
or'42'
- Replace
$TEMPORARY$string<"foo">
withstring
or"foo"
- We have provided a flow-runner codemod via the
flow-upgrade
package to aid larger codebases with this conversion:yarn run flow-codemod replaceTemporaryTypes path/to/src
.
- Replace
- The inferred type for
Object.freeze({ A: 'a', B: 'b' })
is now{+A:'a',+B:'b'}
both locally within a file and when the object is being exported. This replaces an earlier unsound behavior where the type of A would opportunistically behaved either asstring
or'a'
depending on the context where it appeared. - React string refs are now banned.
contextTypes
andchildContextTypes
in react class components are now empty typed, so declaring legacy context in React will be an error.- Component syntax component and component types' ref prop now must have
React.RefSetter<...>
type.
Parser:
- Component type in parentheses can now be correctly parsed. e.g.
type Foo = (component(x: number) renders Bar);
- Trailing comma is now allowed after rest parameter in component syntax components and component types.
- The v regex flag is now supported.
IDE:
- We now provide a code action to stub out a react component, at the location of an unbound JSX identifier.
- Component declaration/type without renders clause will no longer show
renders React.Node
on hover. - Hovering on components will now consistently show its props and renders information. Previously, the information is omitted for component declarations.
- If we see
: renders <annot>
at the position that expects a render declaration, the quickfix will suggest removing:
instead of replacing:
withrenders
.
Library Definitions:
- Added type for
util.stripVTControlCharacters
for NodeJS.
v0.247.1
Misc:
- Performance optimization for unions