Skip to content

Releases: facebook/flow

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.

v0.248.1

12 Oct 05:15
Compare
Choose a tag to compare

IDE:

  • React.Component annotated exported will now also show up in auto-imports in a type position.

v0.248.0

11 Oct 04:07
Compare
Choose a tag to compare

Breaking changes:

  • Support for long deprecated predicate function (%checks) is removed. It will still parse, but all of them will error with unsupported-syntax, and %checks will be completely ignored for type checking purpose as if it doesn't exist.
  • $TupleMap support is now removed. $TupleMap will now resolve to the global definition is there is one, or it will fail and the type becomes any.

Likely to cause new Flow errors:

  • Support for the unsound $TEMPORARY$* types is dropped. If your codebase happens to have any of these types, you can replace them with there sound and well-documented equivalents:
    • Replace $TEMPORARY$object<{props}> with $ReadOnly<{props}> or {props}
    • Replace $TEMPORARY$array<T> with $ReadOnlyArray<T> or Array<T>
    • Replace $TEMPORARY$number<42> with number or '42'
    • Replace $TEMPORARY$string<"foo"> with string or "foo"
    • We have provided a flow-runner codemod via the flow-upgrade package to aid larger codebases with this conversion: yarn run flow-codemod replaceTemporaryTypes path/to/src.
  • The inferred type for Object.freeze({ A: 'a', B: 'b' }) is now {+A:'a',+B:'b'} both locally within a file and when the object is being exported. This replaces an earlier unsound behavior where the type of A would opportunistically behaved either as string or 'a' depending on the context where it appeared.
  • React string refs are now banned.
  • contextTypes and childContextTypes in react class components are now empty typed, so declaring legacy context in React will be an error.
  • Component syntax component and component types' ref prop now must have React.RefSetter<...> type.

Parser:

  • Component type in parentheses can now be correctly parsed. e.g. type Foo = (component(x: number) renders Bar);
  • Trailing comma is now allowed after rest parameter in component syntax components and component types.
  • The v regex flag is now supported.

IDE:

  • We now provide a code action to stub out a react component, at the location of an unbound JSX identifier.
  • Component declaration/type without renders clause will no longer show renders React.Node on hover.
  • Hovering on components will now consistently show its props and renders information. Previously, the information is omitted for component declarations.
  • If we see : renders <annot> at the position that expects a render declaration, the quickfix will suggest removing : instead of replacing : with renders.

Library Definitions:

  • Added type for util.stripVTControlCharacters for NodeJS.

v0.247.1

27 Sep 18:46
Compare
Choose a tag to compare

Misc:

  • Performance optimization for unions