Releases: facebook/flow
Releases · facebook/flow
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.
v0.245.2
Misc:
- The language for invalidated refinement is slightly tweaked. Instead of saying refactoring to a constant, we now say refactoring to a const variable.
v0.245.1
Website:
- Refined expressions are now highlighted in try-flow playground. Hovering on refined expressions will show where it's refined, and hovering on some invalidated property refinements will show the location and reason of the invalidation.
IDE:
- Flow now responds to
textDocument/prepareName
LSP request. This ensures that Flow's rename support can be surfaced when multiple VSCode extension adds rename support for JS files.
v0.245.0
Likely to cause new Flow errors:
React.Element
type, deprecated in 0.243.0, is now removed.- Fixed a bug where refinements are incorrectly not invalidated. example
- Under custom jsx pragma, children is no longer incorrectly added to props. Some spurious errors will be gone. example
New Features:
- Added LSP signature help support for JSX attributes. The feature is triggered with the opening
{
of a JSX attribute value. - Flow now allows to configure the typing of jsx creation under the new option
react.custom_jsx_typing=true
. Under this flag, Flow will type check jsx by through your self-defined global typeReact$CustomJSXFactory
type, which should be a function type that accepts arguments according to jsx spec. e.g. You can write a loose one liketype React$CustomJSXFactory = (component: any, props: any, ...children: any) => React.MixedElement
Notable bug fixes:
- Fixed jsdoc attachment to signature help results for overloaded functions. (example)
- Signature help on overloaded functions will show information in the correct order of signatures
- Labels of autocomplete on members will indicate if the property is optional with a "?"
- Fixed a bug where a type-only namespace within a namespace is accidentally dropped. This bug used to make
globalThis.React.Node
being incorrectly unavailable. - Fixed poor interaction of "Add missing attributes" quickfix when Linked Editing Range is enabled.
- Clicking on related symbol location on hover will jump to the right location in VSCode. Previously it incorrectly jumped to the position 1 character left of the right location.
IDE:
- Elements of component syntax components (e.g. typeof
<A />
where A is in component syntax) will no longer be shown in hover with shorthand syntax likeA
. Instead, it will be shown asReact$Element<typeof A>