Releases: facebook/flow
Releases · facebook/flow
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>
v0.244.0
Likely to cause new Flow errors:
- The
inexact_tuple_types_syntax
option (which was on by default) is now deleted. Make sure you are usinghermes-parser
and related packages at version >= 0.23.0 - Render types will no longer allow specific renders wrapping more general renders like
renders React.Element<React.AbstractComponent<{}, mixed, renders* A>>
. Invalid render types will behave like any. - Some previously allowed generic render types are no longer allowed (example). This ensures that generic render types are only used to model transparent components like
React.Fragment
. renders* T
whereT
is generic is now banned.
Notable bug fixes:
- Render type with union type arguments will be correctly wrapped with parentheses.
v0.243.0
Likely to cause new Flow errors:
- All
deprecated-type
anduntyped-type-import
lint are on and at error level by default. - Use of some internal types of Flow that have other identical public-facing variants (e.g.
React$ElementConfig
vsReact.ElementConfig
) are now a lint error that's enabled by default. To disable it, setinternal-type=off
in the lints section of the flowconfig. For now, these types are still allowed in libdef files, but we plan to also disallow it in the future. To codemod existing code, get the latestflow-upgrade
package and runyarn run flow-codemod replaceReactDollarUtilityTypes
- Direct use of
React$Element
type is banned via theinternal-type
lint. TheReact.Element
alias still exists for now, but it is marked with@deprecated
in the jsdoc. Please read the jsdoc for better alternatives. A global aliasExactReactElement_DEPRECATED
is added to help you clearly mark the use of exact React element types, and you should use it to replaceReact.Element
that you cannot replace without compromising runtime type safety. - Flow now consistently errors on bad comparison with enums example
New Features:
- Allow generic bound by inexact tuple as function rest args. This example now works.
- Support for
declare component
statement andcomponent
type is enabled by default. - Flow now provide the "insert inferred type as type cast" code action. You only need to select the expression in the editor to trigger the code action.
Notable bug fixes:
- Fixed a bug that causes an internal error. example
Misc:
experimental.namespaces
config option is removed. Namespaces support is enabled by default in the previous release.
Library Definitions:
- Add
.replaceChildren
method type definition for dom nodes. Object.getPrototypeof
is still special cased, but the special-casing is only available for a syntacticObject.getPrototypeof(...)
call. If you try to useObject.getPrototypeof
in some other ways (e.g.const f = Object.getPrototypeof; f(...)
), you will get a a less precise and accurate typing for it. TheObject$GetPrototypeOf
type, which was used to back the special case behavior, is removed.
v0.242.1
New Features:
- For
Pick
utility type with string literals in the second type argument, go-to-definition on the string literal will jump to corresponding prop's location
Notable bug fixes:
- Re-exported types will show in autoimports from files without any import statement.
v0.242.0
Likely to cause new Flow errors:
- Support for special function type
$Flow$DebugPrint
was removed. To see the internal representation of type, use theflow type-at-pos
command with flag--debug-print-internal-repr
. Note that this is for debugging purpose only, and you should never depend on the output of--debug-print-internal-repr
- More invalid compare errors will be consistently caught when using
==
and!=
. invalid-render
errors can no longer be suppressed without specific error code.- Flow can now detect more bad cyclic types, including across module boundaries. example
- You may see some errors moved around when
$Exact<...>
is involved. Some invalid$Exact<...>
type will now havenot-an-object
error code. - Fixed a bug that makes some exported types accidentally any. Previously hidden errors might be exposed.
New Features:
declare namespace
support is enabled by default.- Added "Add Missing Attributes" quickfix for JSX. This is available when the cursor is over the name of a JSX element that is missing a required attribute.
- Added a
StringSuffix
type, which goes along with the recently addedStringPrefix
type.StringSuffix
can be used to type strings with a specified suffix. E.g.StringSuffix<'!'>
allows for'yay!'
and'woo!'
. The type argument for the suffix must be a string literal. The second, optional, type argument can be used for the type of the remainder of the string after the suffix is removed.
Notable bug fixes:
- Fix a bug that caused Flow to infer incorrect render types for elements of polymorphic components under niche circumstances
IDE:
- Flow now supports symlinked node_modules in autoimports better. If allowed by the node resolution algorithm, autoimport will insert import specifier like
my-package
ormy-package/foo
instead of a relative path import.
Library Definitions:
- CredMgmtCredentialRequestOptions properties are now optional
Reflect.setPrototypeof
are no longer special-cased, and the backing special typeObject$SetPrototypeOf
is removed. The new typing is intentionally loose. Similar toObject.setPrototypeof
, this is inherently unsafe since Flow won't track prototype mutations.Object.assign
is still special cased, but the special-casing is only available for a syntacticObject.assign(...)
call. If you try to use Object.assign in some other ways (e.g.const f = Object.assign; f(...)
), you will get a a less precise and accurate typing for it. If you don't like the default fallback type, you can override theObject$Assign
type. While the special-casing behavior will stay for the syntactic call, you should migrate your code to use the spread syntax instead.
v0.241.0
No changes from 0.240.0