Skip to content

Releases: facebook/flow

v0.245.2

05 Sep 05:55
Compare
Choose a tag to compare

Misc:

  • The language for invalidated refinement is slightly tweaked. Instead of saying refactoring to a constant, we now say refactoring to a const variable.

v0.245.1

04 Sep 07:41
Compare
Choose a tag to compare

Website:

  • Refined expressions are now highlighted in try-flow playground. Hovering on refined expressions will show where it's refined, and hovering on some invalidated property refinements will show the location and reason of the invalidation.

IDE:

  • Flow now responds to textDocument/prepareName LSP request. This ensures that Flow's rename support can be surfaced when multiple VSCode extension adds rename support for JS files.

v0.245.0

30 Aug 01:18
Compare
Choose a tag to compare

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 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:

  • 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 like A. Instead, it will be shown as React$Element<typeof A>

v0.244.0

17 Aug 22:29
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • The 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.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 where T is generic is now banned.

Notable bug fixes:

  • Render type with union type arguments will be correctly wrapped with parentheses.

v0.243.0

07 Aug 21:45
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • All deprecated-type and untyped-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 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
  • Direct use of 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.
  • 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 and component 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 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.

v0.242.1

30 Jul 01:57
Compare
Choose a tag to compare

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

29 Jul 16:32
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • Support for special function type $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
  • 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 have not-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 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:

  • 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 or my-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 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.

v0.241.0

17 Jul 22:27
Compare
Choose a tag to compare

No changes from 0.240.0

v0.240.0

17 Jul 16:50
Compare
Choose a tag to compare

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 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.
  • 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, not empty.

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 of StringPrefix<'$', '1' | '2'>, but "$999" is not. StringPrefix<X> is equivalent to StringPrefix<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 returns number | void

v0.239.1

08 Jul 19:52
Compare
Choose a tag to compare

Notable bug fixes:

  • Fixed a bug where IDE services doesn't respect files.implicitly_include_root=false config.