Releases: facebook/flow
Releases · facebook/flow
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
v0.247.0
Breaking changes:
- Support for the deprecated
$Call
type is removed.$Call
will now resolve to whatever$Call
points to in the global libdef. If you need more time to migrate, you can create a shim like$Call<F, T> = $TupleMap<[T], F>[0]
, but please note that we intend to remove support for$TupleMap
eventually. deprecated-type-dollar-call
lint is removed, since the support for$Call
is removed.react.disable_function_components_default_props
config option is removed. It is on by default since v0.238.
Likely to cause new Flow errors:
$TupleMap
is deprecated and will be soon removed, now that mapped type works on array inputs. Existing$TupleMap
will still work in this release, but every use will trigger adeprecated-type
lint that is on by default.- Flow now performs literal subtyping checks for strict equality conditions in non-refinement contexts. example
- Fixed destructuring with invalid literal defaults. The following now errors properly: example
- Using string ref on components that are definitely not a class component is now an error. example
- React utility types will no longer incorrectly accept hook types when they expect component types. e.g.
type A = React$ElementConfig<hook (props: {foo: string}) => void>;
will now error.
New Features:
- Refinements against negated bigint literals should now work.
Notable bug fixes:
- Mapped type on generic arrays is now supported. Previously it will fail with array is not an object error.
flow-remove-types
now correctly handlesas
cast with generics.
IDE:
- On hover, values that have
React.AbstractComponent
type will be shown in the component type syntax - Flow now offers a code action to insert inferred render type when you hover on the name of the component.
- Flow now provides keyword completion for component type, hook types and render types.
Library Definitions:
- Overly restrictive typing of queueMicrotask is now fixed.
v0.246.0
Likely to cause new Flow errors:
- Support for $ObjMap has been completely removed. This change means that:
$ObjMap
will resolve to a user-defined$ObjMap
global if it's available in your libdef. You can usetype $ObjMap<O, F> = {[K in keyof O]: $Call<F, O[K]>}
to get most of the same behavior, except that in the mapped type versionO[K]
will include void for optional props. Please note that this should be considered as a permanent shim, because we intend to eventually remove$Call
.flow codemod key-mirror
command was removed, since this codemod tries to convert$ObjMap
to$KeyMirror
deprecated-type-objmap
lint was removed.
- Component syntax components without ref prop will have
void
as the instance, soReact.ElementRef<component>
of such component will return void.
New Features:
- Mapped types now support array and tuple types in the form of
{[K in keyof <array or tuple type>: <mapped type>}
.- With this support, we intend to deprecate $TupleMap in the next release and remove the support for $TupleMap eventually
- You can now refine against variables and member expressions with a literal type, not just literal themselves.
Notable bug fixes:
- Flow now only reports one error when two disjoint large enum-like unions are compared (example).
IDE:
- Code actions on component syntax components will produce smaller targeted edits, rather than reprint the entire component.
- Deprecated utility type like $Call are no longer suggested in autocomplete.
- Flow will now provide a quick fix when the spread prop of a component with component syntax redefines some already defined props.
Library Definitions:
React.Ref
is marked as deprecated. UseReact.RefSetter
instead for ref props, andReact.RefObject
for returns ofuseRef
.React.RefSetter
now includes null and void.Promise.all
andPromise.allSettled
have been updated to use mapped type instead of$TupleMap
. The requirement on the type arguments are slightly changed.