Releases: facebook/flow
Releases · facebook/flow
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
v0.240.0
Likely to cause new Flow errors:
- We fixed a bug that causes Flow to incorrectly believe that the LHS of logical operators are not nullable. example
- Flow can now detect more kinds of bad cyclic types. (example)
- Flow will now consistently catch some invalid comparison of the kind
obj.type === 'foo'
. example - Fixed a bug in the type guard refinement that involves sentinel properties (e.g. try-Flow)
Function.prototype.apply
andFunction.prototype.call
are now typed using userland types instead of hardcoded builtin support. You might see slight inference differences, error message and code changing as a result.- Flow now enforces that only function types are assigned to the
.constructor
property of object types. (D58538540 pvekris) - Fix subtyping checks of unions of bigint types against other unions of bigints.
- Make array holes be typed as
void
, notempty
.
New Features:
- You can now pass in an (optional) second type argument to the
StringPrefix
utility type. This is the type of the remainder of the string after the prefix is removed. For example,"$1"
,"$2"
are subtypes ofStringPrefix<'$', '1' | '2'>
, but"$999"
is not.StringPrefix<X>
is equivalent toStringPrefix<X, string>
- You can use the
$Values
utility type to get the type of the elements of an array type or tuple type. - You can now do sentinel refinements on tuples, like you can already do for objects. This is especially useful for function arguments (you can type the
...args
as a union of tuples). [example] - Sentinel refinements now work when using number keys on objects [example]
- Flow now keep original type after invalid object prop-exists refinement on write-only property.
Notable bug fixes:
- Some operations can now be performed on an opaque type with appropriate bounds. example
- Fixed a bug that occurs when you have a tuple type spread after two or more non-spread arguments. Those will now be resolved in the correct order.
Library Definitions:
String.codePointAt
now returnsnumber | void
v0.239.1
Notable bug fixes:
- Fixed a bug where IDE services doesn't respect
files.implicitly_include_root=false
config.
v0.239.0
Likely to cause new Flow errors:
- We now detect errors when props of React components using component syntax, or hook argument/return values of React hooks using hook syntax, contain arrays, sets, or maps that are mutated using their methods (
Array.push
,Set.add
,Map.set
, etc). These values are expected to be read-only, and we previously errored on directly setting their props; this release extends this enforcement to method calls as well. - We are adding more strict checking for type guard functions to account for the refinement happening in the else branch of conditionals that use them (see docs for more information). You might see new errors appear in the declaration of type guards. One way to address these is by turning the type guard definition to one-sided, by adding
implies
before the type guard (example try-Flow)
New Features:
- The
StringPrefix
type represents strings which being with the specified prefix. E.g.StringPrefix<'data-'>
allows for'data-floo'
and'data-bar'
. The type argument for this type must be a string literal. [example] - Flow now supports
globalThis
.
Notable bug fixes:
- Fixed an issue since 0.232.0 that will cause failure to connect to Flow server if libdef has parse errors.
- Made the "extract to function" refactoring more robust to errors during code synthesis.
- Fixed a bug that can cause hover to hang forever for recursive namespaces. example
- Go-to-definition on
new C()
will jump to definition ofC
instead of the constructor definition. Hovering onC
will still show the jsdoc on the constructor. - Strip
as const
casts andas
casts inflow-remove-types
IDE:
- Hover will show a list of all the symbols found in the inferred type and the locations where they are defined. VSCode LSP and CLI are supported. The LSP version includes a link to the definition. The CLI version only shows the name of the file (no path)
Library Definitions:
- Calling
shift()
andpop()
on anArray<T>
will now returnT | undefined
. - Add
cause
property on Error instance; Support error cause in error constructor options - Add type definition for
FinalizationRegistry
- Add type definition for
CSSSupportsRule
- Add
closeAllConnections
,closeIdleConnections
tohttps$Server
v0.238.3
Misc:
- In v0.238.1 and v0.238.2, we have bumped the required GLIBC version to v2.35 on Linux. We have now reduced the requirement to v2.31 for x86_64 build of Linux.