Skip to content

Releases: facebook/flow

v0.257.1

20 Dec 23:07
Compare
Choose a tag to compare

Misc:

  • Flow language server will stop advertising that we can handle all code actions kinds prefixed with "source". It can help to prevent VSCode sending flow irrelevant code actions to handle during save.

v0.257.0

18 Dec 23:07
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • We have improved inference for exported primitive literal values.
    • Before this change the inferred type for export const obj = {f: "foo"}; was {f: str<"foo">}, where str<"foo"> was a type that opportunistically and unsoundly behaved either as string or as the singleton type "foo".
    • Flow will now infer the type {f: string} for obj.
    • For const like exports, e.g. export const x = "foo"; Flow will export the type "foo".
    • To fix errors that arise due to this change, you can provide annotations around exported literals or use the as const modifier.
  • We fixed a major unsoundness with regards to dictionary object creation. Previously, the computed property will just be ignored for string or any keys. Now, if the computed property is added to some existing objects (e.g. {foo: string, [stringTypedKey]: v}), then we will error on the property. Otherwise, the {[key]: value} will be {[typeof key}: typeof value}
  • We fixed a bug that causes opaque type's underlying representation to leak beyond the file it's defined. You might see more errors as a result.
  • Flow will now perform a complete function call check even when [react-rule-unsafe-mutation] errors are raised.
  • Previously we incorrectly distribute-over-union for maybe or optional input types of conditional type. (e.g. (?string) extends string ? true : false is evaluated to true | false instead of false). This is now fixed, and code that depends on the bug might have new errors.
  • If you have refiend a value based on typeof x === 'function', and then do typeof x === 'object', the result is now empty as that is impossible.
  • Singleton types are now also considered in conditional equality checks on member expressions. (e.g. try-Flow)
  • React.Config type, deprecated in v0.254, is now removed.

New Features:

  • 'key' in x now refines the type of x to objects which have the property key.
    • in checks for both own and non-own properties.
    • If we find that a key does not exist in an inexact object or instance/interface, then the negation is not refined since the property may or may not exist.
    • An optional property is also considered as if it may or may not exist.
    • If a proto/super is a union, every member of the union must have it
    • If the input to the refinement is an intersection, one member of that intersection must have it
    • We don't refine arrays since it's not useful (check for .length instead), and also because Flow doesn't handle array holes.
  • Flow now supports no_unchecked_indexed_access=true in flowconfig, which is equivalent to noUncheckedIndexedAccess from TS. It will add | void to every indexed access with general string key on dictionary objects or number key on arrays.
  • Support for React 19's ref-as-prop model is now available via react.ref_as_prop=partial_support, and this is now the default. (To disable it, use react.ref_as_prop=disabled.) Under this mode, ref prop in jsx will be treated as a regular prop for function components, but utility types like React.ElementConfig<...> still won't include the regular ref prop yet.
  • Flow now allows using union of strings as the type of computed property keys.
  • You can now destructure object properties using number literal keys (which are int-like).

Notable bug fixes:

  • Refining type guards with opaque types will now refine the general type (example of code that used to fail before, but now passes: try-Flow)
  • Allow more flexibility in checks involving super type of opaque type (e.g. try-Flow)
  • Fixed a bug when using opaque types in type guards in files other than the one where the type guard function was defined.
  • We now allow a union of generic or opaque string typed values to be used as a key of computed property, if it's bounded by a string type.

Library Definitions:

  • Add libdef types for getNotifications and showNotification API for ServiceWorkerRegistration

v0.256.0

06 Dec 01:37
Compare
Choose a tag to compare

Notable bug fixes:

  • Fixed a limitation when checking intersections of polymorphic types (e.g. tryFlow)
  • Fixed an internal error raised when using super in an object method. Such cases are now user-facing errors.

v0.255.0

25 Nov 22:25
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • Referencing a react-component typed value in type position will now create a React$RendersExactly<typeof Component> type instead of React$Element<typeof Component> type. All existing usages intended to create an exact react element will now error as a result. Using it as type passed to render type, React.PropsOf, React.PropOf and React.RefOf is unaffected and will not be affected in the future. If you want exact react elements, the only way that doesn't trigger Flow error is by ExactReactElement_DEPRECATED<typeof Component>.

Library Definitions:

  • React.Config type is marked as deprecated and will be removed soon. You can create your own equivalent type with
type ReactConfigShim<Props, DefaultProps> = $ReadOnly<{
  ...Omit<Props, $Keys<DefaultProps>>, ...Partial<DefaultProps>
}>;

v0.254.2

22 Nov 18:00
Compare
Choose a tag to compare

Misc:

  • Add option to disable experimental configuration

v0.254.1

21 Nov 17:48
Compare
Choose a tag to compare

Notable bug fixes:

  • Fixed a potential crash when experimental multiplatform support is enabled.

v0.254.0

20 Nov 16:38
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • Previously we incorrectly applied truthy refinement on optional chaining where it shouldn't be applied. The issue is now fixed, and you might see change in behavior similar to these examples

Library Definitions:

  • Improve Array toSpliced method type (thanks @aph!)

v0.253.0

14 Nov 20:07
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • React$ElementRef is now implemented with a conditional type instead of a builtin Flow utility type. You might see new errors with generic React$ElementRef. Most of the times, you should replace React.ElementRef<T> with just T if there are no other uses of generic T.
  • We've increased safety in checks involving recursive types.

New Features:

  • You can now set multiple @flowtyped like directories via module.declaration_dirnames config. e.g.
module.declaration_dirnames=<PROJECT_ROOT>/decl1
module.declaration_dirnames=<PROJECT_ROOT>/decl2

Please note that when you set this, @flowtyped at the root will no longer be considered special, and you will need to explicitly add it like

module.declaration_dirnames=<PROJECT_ROOT>/@flowtyped

Notable bug fixes:

  • A generic type as input to conditional type will have type parameters pinned with their default or upper bound, instead of being empty.
  • We fixed a cache collision issue that might cause instantiation of a value-imported generic component type to interfere with a typeof-imported generic component type.

IDE:

  • Flow now respects includeDeclaration from LSP request for find-references command. In practice, this means that "find all references" in vscode will continue to return both declaration and all uses, while "go to references" will exclude the declaration.

v0.252.0

07 Nov 06:56
Compare
Choose a tag to compare

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

30 Oct 20:19
Compare
Choose a tag to compare

Misc:

  • Performance fix