Skip to content

Releases: facebook/flow

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

v0.251.0

29 Oct 18:10
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • Remove the deprecated React.AbstractComponent type. We recommend replacing them with component types. Since v0.249.0, we have provided a codemod via the flow-upgrade package to aid larger codebases with this conversion: yarn run flow-codemod eliminateAbstractComponent path/to/src.
  • In addition to the removal of React.AbstractComponent type, we also removed support for the internal React$AbstractComponent when more than 1 type argument has been passed. Similarly, you should migrate to use component types if you want to specify ref props and renders.

New Features:

  • We now support a new way to easily specify library definitions for npm modules. For all files in @flowtyped directory at the root, they can be resolved by the relative path without leading ./ relative to @flowtyped. e.g. <PROJECT_ROOT>/@flowtyped/react.js.flow can be used to type the react package, and <PROJECT_ROOT>/@flowtyped/react/jsx-runtime.js.flow can be used to type react/jsx-runtime module. We now recommend using this approach instead of using declare module in global libdef.

Notable bug fixes:

  • any will now correctly propagate to inferred render type. example.
  • Fixed a bug with regard to jsx type inference with generic callable objects. example
  • Fixed a soundness hole that allowed frozen objects to be incompatible with non-readonly objects. This example will now produce an error.

Library Definitions:

  • We have updated some core React type definitions to use the new component type instead of React.AbstractComponent. Most of the code won't be affected, but you might have to sometimes make the Props readonly.

v0.250.0

17 Oct 23:00
Compare
Choose a tag to compare

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 of flow-remove-types, we now respect it and will correctly handle Flow-typed files without @flow pragma.

v0.249.0

16 Oct 23:54
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • Uses of React$AbstractComponent outside library definitions will now trigger internal-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 the flow-upgrade package to aid larger codebases with this conversion: yarn run flow-codemod eliminateAbstractComponent path/to/src.

Notable bug fixes:

  • Fixed issue with StringPrefix and StringSuffix 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 in flow-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.