Adds static typing to JavaScript to improve developer productivity and code quality.
MIT License
Bot releases are visible (Hide)
Published by facebook-github-bot 26 days ago
Misc:
Published by facebook-github-bot 27 days ago
Breaking changes:
$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 a deprecated-type
lint that is on by default.type A = React$ElementConfig<hook (props: {foo: string}) => void>;
will now error.New Features:
Notable bug fixes:
flow-remove-types
now correctly handles as
cast with generics.IDE:
React.AbstractComponent
type will be shown in the component type syntaxLibrary Definitions:
Published by facebook-github-bot about 1 month ago
Likely to cause new Flow errors:
$ObjMap
will resolve to a user-defined $ObjMap
global if it's available in your libdef. You can use type $ObjMap<O, F> = {[K in keyof O]: $Call<F, O[K]>}
to get most of the same behavior, except that in the mapped type version O[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.void
as the instance, so React.ElementRef<component>
of such component will return void.New Features:
{[K in keyof <array or tuple type>: <mapped type>}
.
Notable bug fixes:
IDE:
Library Definitions:
React.Ref
is marked as deprecated. Use React.RefSetter
instead for ref props, and React.RefObject
for returns of useRef
.React.RefSetter
now includes null and void.Promise.all
and Promise.allSettled
have been updated to use mapped type instead of $TupleMap
. The requirement on the type arguments are slightly changed.Published by facebook-github-bot about 2 months ago
Misc:
Published by facebook-github-bot about 2 months ago
Website:
IDE:
textDocument/prepareName
LSP request. This ensures that Flow's rename support can be surfaced when multiple VSCode extension adds rename support for JS files.Published by facebook-github-bot about 2 months ago
Likely to cause new Flow errors:
React.Element
type, deprecated in 0.243.0, is now removed.New Features:
{
of a JSX attribute value.react.custom_jsx_typing=true
. Under this flag, Flow will type check jsx by through your self-defined global type React$CustomJSXFactory
type, which should be a function type that accepts arguments according to jsx spec. e.g. You can write a loose one like type React$CustomJSXFactory = (component: any, props: any, ...children: any) => React.MixedElement
Notable bug fixes:
globalThis.React.Node
being incorrectly unavailable.IDE:
<A />
where A is in component syntax) will no longer be shown in hover with shorthand syntax like A
. Instead, it will be shown as React$Element<typeof A>
Published by facebook-github-bot 2 months ago
Likely to cause new Flow errors:
inexact_tuple_types_syntax
option (which was on by default) is now deleted. Make sure you are using hermes-parser
and related packages at version >= 0.23.0renders React.Element<React.AbstractComponent<{}, mixed, renders* A>>
. Invalid render types will behave like any.React.Fragment
.renders* T
where T
is generic is now banned.Notable bug fixes:
Published by facebook-github-bot 3 months ago
Likely to cause new Flow errors:
deprecated-type
and untyped-type-import
lint are on and at error level by default.React$ElementConfig
vs React.ElementConfig
) are now a lint error that's enabled by default. To disable it, set internal-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 latest flow-upgrade
package and run yarn run flow-codemod replaceReactDollarUtilityTypes
React$Element
type is banned via the internal-type
lint. The React.Element
alias still exists for now, but it is marked with @deprecated
in the jsdoc. Please read the jsdoc for better alternatives. A global alias ExactReactElement_DEPRECATED
is added to help you clearly mark the use of exact React element types, and you should use it to replace React.Element
that you cannot replace without compromising runtime type safety.New Features:
declare component
statement and component
type is enabled by default.Notable bug fixes:
Misc:
experimental.namespaces
config option is removed. Namespaces support is enabled by default in the previous release.Library Definitions:
.replaceChildren
method type definition for dom nodes.Object.getPrototypeof
is still special cased, but the special-casing is only available for a syntactic Object.getPrototypeof(...)
call. If you try to use Object.getPrototypeof
in some other ways (e.g. const f = Object.getPrototypeof; f(...)
), you will get a a less precise and accurate typing for it. The Object$GetPrototypeOf
type, which was used to back the special case behavior, is removed.Published by facebook-github-bot 3 months ago
New Features:
Pick
utility type with string literals in the second type argument, go-to-definition on the string literal will jump to corresponding prop's locationNotable bug fixes:
Published by facebook-github-bot 3 months ago
Likely to cause new Flow errors:
$Flow$DebugPrint
was removed. To see the internal representation of type, use the flow 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
==
and !=
.invalid-render
errors can no longer be suppressed without specific error code.$Exact<...>
is involved. Some invalid $Exact<...>
type will now have not-an-object
error code.New Features:
declare namespace
support is enabled by default.StringSuffix
type, which goes along with the recently added StringPrefix
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:
IDE:
my-package
or my-package/foo
instead of a relative path import.Library Definitions:
Reflect.setPrototypeof
are no longer special-cased, and the backing special type Object$SetPrototypeOf
is removed. The new typing is intentionally loose. Similar to Object.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 syntactic Object.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 the Object$Assign
type. While the special-casing behavior will stay for the syntactic call, you should migrate your code to use the spread syntax instead.Published by facebook-github-bot 3 months ago
No changes from 0.240.0
Published by facebook-github-bot 3 months ago
Likely to cause new Flow errors:
obj.type === 'foo'
. example
Function.prototype.apply
and Function.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..constructor
property of object types. (D58538540 pvekris)void
, not empty
.New Features:
StringPrefix
utility type. This is the type of the remainder of the string after the prefix is removed. For example, "$1"
, "$2"
are subtypes of StringPrefix<'$', '1' | '2'>
, but "$999"
is not. StringPrefix<X>
is equivalent to StringPrefix<X, string>
$Values
utility type to get the type of the elements of an array type or tuple type....args
as a union of tuples). [example]
Notable bug fixes:
Library Definitions:
String.codePointAt
now returns number | void
Published by facebook-github-bot 4 months ago
Notable bug fixes:
files.implicitly_include_root=false
config.Published by facebook-github-bot 4 months ago
Likely to cause new Flow errors:
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.implies
before the type guard (example try-Flow)New Features:
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]
globalThis
.Notable bug fixes:
new C()
will jump to definition of C
instead of the constructor definition. Hovering on C
will still show the jsdoc on the constructor.as const
casts and as
casts in flow-remove-types
IDE:
Library Definitions:
shift()
and pop()
on an Array<T>
will now return T | undefined
.cause
property on Error instance; Support error cause in error constructor optionsFinalizationRegistry
CSSSupportsRule
closeAllConnections
, closeIdleConnections
to https$Server
Published by facebook-github-bot 4 months ago
Misc:
Published by SamChou19815 4 months ago
Notable bug fixes:
flow force-recheck
doesn't respect files.implicitly_include_root=false
config.Published by SamChou19815 4 months ago
This release is used to test the release automation powered by GitHub Actions. No changes are expected.
Published by facebook-github-bot 4 months ago
Likely to cause new Flow errors:
react.disable_function_components_default_props
that will make Flow ignore defaultProps
on function components for React component typing purposes. This flag is now on by default. If this is too disruptive for your codebase, you can turn this off for now. Note that we do not intend to keep this flag forever, so you should try to turn this flag on as soon as possible.React.createElement
have an opaque type, which means calling this function directly will be an error. This will be helpful to prepare for React 19 changes. Note that JSX typing is unaffected. If you are not ready for this change, you can override your library definition like this to approximate the previous behavior as much as possible.invalid-component-prop
error, Flow will no longer make the entire props to be any type. Instead, Flow will create a Props type as if these invalid props do not exist. example
Object.freeze({ A: "a", B: "b" })
as {+A: "a", +B: "b"}
, ie we use readonly properties and singleton types for literal initializers. Casts like this example will now be an error.untyped-import
errors are now on the import source rather than imported names.New Features:
files.implictly_include_root=false
(default is true, which is the current behavior), Flow will no longer include everything under the directory where the flowconfig is in by default.Notable bug fixes:
Array.reduce
and returning a union type (e.g. try-Flow)[...[]] as []
now works.nested-component
errors can now be suppressed.IDE:
({ foo: { | } } as ?{ foo: { x: number }})
it will populate x
, when calling autocomplete at the point of the cursor |
. (try-Flow)React
type-only namespace.<Foo.Bar />
.export {Foo} from 'bar'
statements will now appear in autoimport results.autoimports_ranked_by_usage
is now enabled by default.new C(e)
Library Definitions:
useOptimistic
and useActionState
API definitionsTextDecoderStream
Published by facebook-github-bot 5 months ago
New Features:
react.disable_function_components_default_props=true
, Flow will ignore defaultProps
on function components for React typing purposes. Note that we do not intend to keep this flag forever, so you should try to turn this flag on as soon as possible.Published by facebook-github-bot 5 months ago
Notable bug fixes: