flow

Adds static typing to JavaScript to improve developer productivity and code quality.

MIT License

Downloads
42.1M
Stars
22.1K
Committers
931

Bot releases are visible (Hide)

flow - https://github.com/facebook/flow/releases/tag/v0.247.1

Published by facebook-github-bot 22 days ago

Misc:

  • Performance optimization for unions
flow - https://github.com/facebook/flow/releases/tag/v0.247.0

Published by facebook-github-bot 23 days ago

Breaking changes:

  • Support for the deprecated $Call type is removed. $Call will now resolve to whatever $Call points to in the global libdef. If you need more time to migrate, you can create a shim like $Call<F, T> = $TupleMap<[T], F>[0], but please note that we intend to remove support for $TupleMap eventually.
  • deprecated-type-dollar-call lint is removed, since the support for $Call is removed.
  • react.disable_function_components_default_props config option is removed. It is on by default since v0.238.

Likely to cause new Flow errors:

  • $TupleMap is deprecated and will be soon removed, now that mapped type works on array inputs. Existing $TupleMap will still work in this release, but every use will trigger a deprecated-type lint that is on by default.
  • Flow now performs literal subtyping checks for strict equality conditions in non-refinement contexts. example
  • Fixed destructuring with invalid literal defaults. The following now errors properly: example
  • Using string ref on components that are definitely not a class component is now an error. example
  • React utility types will no longer incorrectly accept hook types when they expect component types. e.g. type A = React$ElementConfig<hook (props: {foo: string}) => void>; will now error.

New Features:

  • Refinements against negated bigint literals should now work.

Notable bug fixes:

  • Mapped type on generic arrays is now supported. Previously it will fail with array is not an object error.
  • flow-remove-types now correctly handles as cast with generics.

IDE:

  • On hover, values that have React.AbstractComponent type will be shown in the component type syntax
  • Flow now offers a code action to insert inferred render type when you hover on the name of the component.
  • Flow now provides keyword completion for component type, hook types and render types.

Library Definitions:

  • Overly restrictive typing of queueMicrotask is now fixed.
flow - https://github.com/facebook/flow/releases/tag/v0.246.0

Published by facebook-github-bot about 1 month ago

Likely to cause new Flow errors:

  • Support for $ObjMap has been completely removed. This change means that:
    • $ObjMap will resolve to a user-defined $ObjMap global if it's available in your libdef. You can use type $ObjMap<O, F> = {[K in keyof O]: $Call<F, O[K]>} to get most of the same behavior, except that in the mapped type version O[K] will include void for optional props. Please note that this should be considered as a permanent shim, because we intend to eventually remove $Call.
    • flow codemod key-mirror command was removed, since this codemod tries to convert $ObjMap to $KeyMirror
    • deprecated-type-objmap lint was removed.
  • Component syntax components without ref prop will have void as the instance, so React.ElementRef<component> of such component will return void.

New Features:

  • Mapped types now support array and tuple types in the form of {[K in keyof <array or tuple type>: <mapped type>}.
    • With this support, we intend to deprecate $TupleMap in the next release and remove the support for $TupleMap eventually
  • You can now refine against variables and member expressions with a literal type, not just literal themselves.

Notable bug fixes:

  • Flow now only reports one error when two disjoint large enum-like unions are compared (example).

IDE:

  • Code actions on component syntax components will produce smaller targeted edits, rather than reprint the entire component.
  • Deprecated utility type like $Call are no longer suggested in autocomplete.
  • Flow will now provide a quick fix when the spread prop of a component with component syntax redefines some already defined props.

Library Definitions:

  • React.Ref is marked as deprecated. Use React.RefSetter instead for ref props, and React.RefObject for returns of useRef.
  • React.RefSetter now includes null and void.
  • Promise.all and Promise.allSettled have been updated to use mapped type instead of $TupleMap. The requirement on the type arguments are slightly changed.
flow - https://github.com/facebook/flow/releases/tag/v0.245.2

Published by facebook-github-bot about 1 month ago

Misc:

  • The language for invalidated refinement is slightly tweaked. Instead of saying refactoring to a constant, we now say refactoring to a const variable.
flow - https://github.com/facebook/flow/releases/tag/v0.245.1

Published by facebook-github-bot about 2 months ago

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.
flow - https://github.com/facebook/flow/releases/tag/v0.245.0

Published by facebook-github-bot about 2 months ago

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>
flow - https://github.com/facebook/flow/releases/tag/v0.244.0

Published by facebook-github-bot 2 months ago

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.
flow - https://github.com/facebook/flow/releases/tag/v0.243.0

Published by facebook-github-bot 2 months ago

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.
flow - https://github.com/facebook/flow/releases/tag/v0.242.1

Published by facebook-github-bot 3 months ago

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.
flow - https://github.com/facebook/flow/releases/tag/v0.242.0

Published by facebook-github-bot 3 months ago

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.
flow - https://github.com/facebook/flow/releases/tag/v0.241.0

Published by facebook-github-bot 3 months ago

No changes from 0.240.0

flow - https://github.com/facebook/flow/releases/tag/v0.240.0

Published by facebook-github-bot 3 months ago

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
flow - https://github.com/facebook/flow/releases/tag/v0.239.1

Published by facebook-github-bot 3 months ago

Notable bug fixes:

  • Fixed a bug where IDE services doesn't respect files.implicitly_include_root=false config.
flow - https://github.com/facebook/flow/releases/tag/v0.239.0

Published by facebook-github-bot 4 months ago

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
flow - https://github.com/facebook/flow/releases/tag/v0.238.3

Published by facebook-github-bot 4 months ago

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.
flow - v0.238.2

Published by SamChou19815 4 months ago

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.
flow - v0.238.1

Published by SamChou19815 4 months ago

This release is used to test the release automation powered by GitHub Actions. No changes are expected.

flow - https://github.com/facebook/flow/releases/tag/v0.238.0

Published by facebook-github-bot 4 months ago

Likely to cause new Flow errors:

  • In v0.237.2, we shipped the flag react.disable_function_components_default_props that will make Flow ignore defaultProps on function components for React component typing purposes. This flag is now on by default. If this is too disruptive for your codebase, you can turn this off for now. Note that we do not intend to keep this flag forever, so you should try to turn this flag on as soon as possible.
  • We made React.createElement have an opaque type, which means calling this function directly will be an error. This will be helpful to prepare for React 19 changes. Note that JSX typing is unaffected. If you are not ready for this change, you can override your library definition like this to approximate the previous behavior as much as possible.
  • When there is an invalid-component-prop error, Flow will no longer make the entire props to be any type. Instead, Flow will create a Props type as if these invalid props do not exist. example
  • We are making the typing of the exported object of a module more strict. If you see errors when casting the exported type of a module to a writable object, try either casting it to a readonly version instead, or casting the exported object to the writable object type.
  • We now infer the type for Object.freeze({ A: "a", B: "b" }) as {+A: "a", +B: "b"}, ie we use readonly properties and singleton types for literal initializers. Casts like this example will now be an error.
  • We now error more consistently when a property is missing from an intersection of objects (e.g. try-Flow)
  • untyped-import errors are now on the import source rather than imported names.

New Features:

  • Under files.implictly_include_root=false (default is true, which is the current behavior), Flow will no longer include everything under the directory where the flowconfig is in by default.

Notable bug fixes:

  • Fixed a category of spurious errors when using Array.reduce and returning a union type (e.g. try-Flow)
  • Explicit type arguments in JSX are now considered for contextual typing. example
  • Fixed spread of empty array when calculating tuple elements, e.g. [...[]] as [] now works.
  • nested-component errors can now be suppressed.

IDE:

  • Flow now suggests properties of objects that are contextually typed with optional types. For example, in ({ foo: { | } } as ?{ foo: { x: number }}) it will populate x, when calling autocomplete at the point of the cursor |. (try-Flow)
  • We now provide autocomplete for types in the global React type-only namespace.
  • We now support go-to-definition for JSX member expression like <Foo.Bar />.
  • Re-exported values from export {Foo} from 'bar' statements will now appear in autoimport results.
  • autoimports_ranked_by_usage is now enabled by default.
  • Flow will now show the type of the constructor of a class (instantiated if it is generic) when hovering over the "new" keyword in new C(e)
  • Hover types will now show the specialized version of a polymorphic component used at a JSX expression
  • Hover types won't add unnecessary parentheses around union types.

Library Definitions:

  • Add React 19 useOptimistic and useActionState API definitions
  • Add libdef for TextDecoderStream
flow - https://github.com/facebook/flow/releases/tag/v0.237.2

Published by facebook-github-bot 5 months ago

New Features:

  • We added a flag to help prepare your codebase for React 19's defaultProps change. defaultProps on function components will no longer work in React 19. Under react.disable_function_components_default_props=true, Flow will ignore defaultProps on function components for React typing purposes. Note that we do not intend to keep this flag forever, so you should try to turn this flag on as soon as possible.
flow - https://github.com/facebook/flow/releases/tag/v0.237.1

Published by facebook-github-bot 5 months ago

Notable bug fixes:

  • Fixed an issue that might cause connecting to flow server to fail with out of retries.