Skip to content

Releases: facebook/flow

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.

v0.239.0

03 Jul 19:53
Compare
Choose a tag to compare

Likely to cause new Flow errors:

  • We now detect errors when props of React components using component syntax, or hook argument/return values of React hooks using hook syntax, contain arrays, sets, or maps that are mutated using their methods (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.
  • We are adding more strict checking for type guard functions to account for the refinement happening in the else branch of conditionals that use them (see docs for more information). You might see new errors appear in the declaration of type guards. One way to address these is by turning the type guard definition to one-sided, by adding implies before the type guard (example try-Flow)

New Features:

  • The 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]
  • Flow now supports globalThis.

Notable bug fixes:

  • Fixed an issue since 0.232.0 that will cause failure to connect to Flow server if libdef has parse errors.
  • Made the "extract to function" refactoring more robust to errors during code synthesis.
  • Fixed a bug that can cause hover to hang forever for recursive namespaces. example
  • Go-to-definition on new C() will jump to definition of C instead of the constructor definition. Hovering on C will still show the jsdoc on the constructor.
  • Strip as const casts and as casts in flow-remove-types

IDE:

  • Hover will show a list of all the symbols found in the inferred type and the locations where they are defined. VSCode LSP and CLI are supported. The LSP version includes a link to the definition. The CLI version only shows the name of the file (no path)

Library Definitions:

  • Calling shift() and pop() on an Array<T> will now return T | undefined.
  • Add cause property on Error instance; Support error cause in error constructor options
  • Add type definition for FinalizationRegistry
  • Add type definition for CSSSupportsRule
  • Add closeAllConnections, closeIdleConnections to https$Server

v0.238.3

27 Jun 16:53
Compare
Choose a tag to compare

Misc:

  • In v0.238.1 and v0.238.2, we have bumped the required GLIBC version to v2.35 on Linux. We have now reduced the requirement to v2.31 for x86_64 build of Linux.

v0.238.2

26 Jun 23:33
Compare
Choose a tag to compare

Notable bug fixes:

  • Fixed a bug where a recheck triggered by flow force-recheck doesn't respect files.implicitly_include_root=false config.
  • Fixed a bug that causes missing results in find-ref and rename.