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 -

Published by facebook-github-bot over 1 year ago

Likely to cause new Flow errors:

  • Don't error for tuple element type incompatibility if we have already errored for invalid tuple arity.
  • Fix a bug that causes certain errors in annotations to be hidden. As a result, more legitimate errors might appear. Example here.

New Features:

  • Add support for optional tuple elements, e.g. ['s'] and ['s', 1] are both valid values for [foo: string, bar?: number].
  • Add autocomplete for keywords to the LSP.
  • Add a code action that inserts jsdoc on a function.
  • exact_by_default=true is now the default value if the option is omitted from the .flowconfig. Read this blog post for more details.

Notable bug fixes:

  • Fix LSP rename command to consider aliased named exports.
  • If a contextually typed parameter has a default, we will filter out null and void from the inferred type of the parameter. This removes spurious errors like this.
  • Some spurious prop-missing errors might be removed. Example here
  • Remove some spurious internal errors of Flow. Example here

Misc:

  • Add option for module.system.haste.module_ref_prefix_LEGACY_INTEROP in the config to allow migration from the automatic_require_default flag and to ES module syntax.

Parser:

  • Include InterpreterDirective in the AST.
  • Fix loc/range of postfix arrays that start with a parenthesis, like (A | B)[].
  • Fix missing error when arrow functions have duplicate params.
flow - v0.201.0

Published by facebook-github-bot over 1 year ago

Local Type Inference:

  • Local Type Inference is a rewrite of Flow’s type inference algorithm. This change makes Flow’s inference behavior more reliable and predictable. It replaces a global inference scheme that Flow has relied on since its inception and that has often been the culprit of confusing action-at-a-distance behavior, in exchange for modestly increased type annotations.
    It is now enabled by default! See this blog post for more details on the new system and steps to upgrade your project.

Likely to cause new Flow errors:

  • When a variable is initialized at declaration, subsequent assignment in a conditional branch will no longer cause later reads to get a union type. This is already the case if the variable is annotated. As a result of this change, you might get new type errors. Example
  • When a variable is uninitialized or initialized to null, we use all the assignments to the variables as its initial type. We now no longer consider assignments from a child generic function. As a result, you might get new invalid-declaration errors. Example
  • Fix object value rest. It will now error if attempting to read a write-only or setter-only property (it reads while copying the properties). Additionally, the resulting rest object will no longer preserve read-only variance (as it is a copy).
  • The type utility $Partial will now preserve the variance of the input object type's properties. For example, if the the input was a read-only object, now that output will also be a read-only object (with optional properties).
  • string and symbol are no longer subtypes of an interface
  • Error on with statements in non-strict mode. It was already a syntax error in strict mode.

New Features:

  • A native Apple Silicon precompiled binary is now available via the GitHub Releases page. It is not yet available via flow-bin. Internally, we see about 2X faster performance than using Rosetta, and 4X faster performance than on actual Intel Macs.
  • Add local variable renaming capabilities to the LSP
  • Add "Find All References" functionality to the LSP for showing local references
  • JSDoc autocomplete will automatically trigger after typing /**
  • Add option for automatically closing JSX tags in the IDE
  • Hovering in the IDE now shows both the unevaluated and evaluated type of the target expression.
  • Add use_mixed_in_catch_variables config option that makes catch variables default to mixed instead of any
  • Rename $Partial utility type to Partial. $Partial will continue working as an alias for at least one more version - use that period of time to codemod it to Partial.
  • Add the Required utility type. It does the opposite of Partial: it makes optional properties required in object types.
  • Improve error when attempting to call Object.values on a Flow Enum, to point the user to using .members()
  • Improve error when using number and boolean primitives as a subtype of an interface
  • Improve error on tuple arity mismatch

Notable bug fixes:

  • Fix a bug preventing annotation hints from being used in tagged template expressions. This fix may get rid of some underconstrained-implicit-instantiation errors that were otherwise impossible to fix.
  • Fix error when autocompleting the method stub for a function type without parameter names
  • Document highlight in the IDE now correctly highlights destructured object keys
  • Autocomplete can suggest literals when the target type is $Keys

flow-upgrade:

  • Add codemod to convert usage of the $Shape utility type to Partial. It is possible that this will create type errors that you will have to resolve.
  • Add codemod to rename $Partial to Partial

Misc:

  • Remove unused-promise-in-async-scope and unused-promise-in-sync-scope. They can be enabled with unused-promise.
  • Remove --evaluate-type-destructors flag from type-at-pos command
  • Add flow save-state --scm flag to ease creation of SCM-aware saved states

Parser:

  • Fix missing decorators on class fields
  • Make infer a reserved word in types
flow - https://github.com/facebook/flow/releases/tag/v0.200.1

Published by facebook-github-bot over 1 year ago

Notable bug fixes:
We fixed a bug that causes spurious Array is not an array errors in try-flow. Example

flow - v0.200.0

Published by facebook-github-bot over 1 year ago

Likely to cause new Flow errors:

  • We now require all generic functions to be fully annotated to prevent generic-escape issues. Some escaped-generic errors will be removed with missing-local-annot errors on return type annotation positions.
  • Under LTI, we will no longer silently give unannotated parameters in destructuring assignment any type. Instead, they will be properly contextually typed. e.g. try Flow example.
  • Some additional errors might be revealed after a correctness fix in implicit instantiation. e.g. try Flow example
  • The exact_by_default option is now required to be set in the [options] section of the .flowconfig. Add either exact_by_default=true or exact_by_default=false to your [options] section. Previously the absence of the option was equivalent to exact_by_default=false. In the future, we will make the absence of the option equivalent to exact_by_default=true. Read more about the option here: https://flow.org/en/docs/config/options/#toc-exact-by-default-boolean. To create a valid new .flowconfig, use flow init.
  • Changes to type variable unification may cause new errors to surface or old errors to be shifted to new locations.
  • Fixed a bug where an unannotated parameter does not cause a missing-local-annot error under LTI. e.g. try Flow example
  • Flow will stop emitting some spurious errors and uncover some hidden bugs under local type inference, as a result of removing a cache that no longer makes sense.
  • The this type of exported classes' methods are no longer unsoundly typed as any. As a result, more underconstrained implicit instantiation errors might show up in LTI.
  • Relational comparisons between dates and numbers are no longer allowed.

New Features:

  • We added flow autofix missing-local-annot command that will try to add annotations to autofix all missing-local-annot errors in a given file.
  • We now provide autofixes in IDE for all missing-local-annot errors where we can locally infer a type. Previously, this kind of autofix is only provided for unannotated parameters.
  • Added an unused-promise-in-sync-scope lint which will detect unused promises in sync scopes (like unused-promise-in-async-scope does for async scopes). Enabling unused-promise will enable both of these rules. The individual rules will be removed in a future release.
  • Pragmas (e.g. // @flow strict, // @jsx custom_jsx_fun) are now supported in try-flow.

IDE:

  • Added autocomplete for jsdoc comments on functions.
  • Added autocomplete for $FlowFixMe comments.
  • Autocomplete will no longer suggest existing type names for type binding identifiers (e.g., in the name of a type alias).

Notable bug fixes:

  • We will no longer warn about missing-local-annot when there is a proper typing context in super call. e.g. super(x => x) will now pass type checking under LTI if the super constructor call expects such function.
  • Builtin types like $ReadOnly will no longer shadow your local definitions with the same name.
  • We will no longer emit spurious errors when we are doing contextual typing while trying to resolve an overload. e.g. try Flow example
  • We fixed a bug that over-zealously uses contextual type information from sibling nodes to type generic function calls. As a result, examples like the following no longer error: try Flow example
  • fixed a bug where optional chaining on a value typed as a type application would not filter out the null or undefined value. e.g. try Flow example
  • Some spurious errors might be removed as a result of Flow doing proper cache invalidation.
  • Fix sorting of auto-imports with the same similarity score and length.

Parser:

  • Parse and error on JSX type arguments.
  • Add custom parse error for abstract classes.
  • Add custom parse error when attempting to use template literal types in Flow.
  • Add custom parse errors for TS class visibility modifiers public/private/protected.
  • Remove function as an alias to Function, and don't allow function as a type name in general. (closes issue #9000).
flow - https://github.com/facebook/flow/releases/tag/v0.199.1

Published by facebook-github-bot over 1 year ago

Notable bug fixes:

  • Fix crash related to deleted files in Haste
flow - v0.199.0

Published by facebook-github-bot over 1 year ago

Likely to cause new Flow errors:

  • Support for spread argument in the builtin special-cased $Compose function is dropped. If you need this, you can write it yourself:
declare function compose<T>(
  fns:...$ReadOnlyArray<T=>T>,
): T;
  • Flow now consistently disallows implicit coercion of dates to numbers. Prefer explicit conversion with getTime().
  • When a type argument is inferred from type argument bound or default, and such inference causes error downstream, we will provide better explanations in the error message where the type is coming from. Examples in try Flow.
  • We fixed a bug under LTI that causes us to incorrectly skip checking for some function expressions Example. Some previously hidden errors might be revealed.
  • We fixed a bug that causes some empty arrays to be incorrectly inferred as Array<empty> under LTI. e.g. Array.from(nullableStringArray ?? []). As a result, previously hidden errors might be revealed.
  • Errors for bad == or === comparisons will now consistently show up. Previously, some errors might be hidden when some optimizations are hit, which heavily depends on the implementation details. Example
  • More missing-local-annot error might be shown in cases when we cannot resolve overload. Example
  • We fixed a bug where an unannotated parameter does not cause a missing-local-annot error under LTI. e.g.
declare function id<T>(T): T;
id([(item) => 1]); // now errors

New Features:

  • Improved behavior of string literal autocomplete. Results will be provided regardless of the quote style used, and extra quotes won't be inserted when one is already typed.
  • Add support for declare let and declare const. These work like declare var, but follow the rules of let and const respectively.

Notable bug fixes:

  • We will no longer emit escaped-generic errors for predicate function bodies.
  • $Compose now works under LTI mode.
  • Remove spurious illegal-this error when a this annotation is used in contextual typing.
  • Under LTI mode, we will no longer emit spurious incompatibility errors in invalid predicate function like function f({a: b}): boolean %checks { return typeof b === 'string'; }. Instead, you will only get error on this unsupported syntax.
  • Fix type created by tagged template literals and String.raw. (Closes #7580. Fixes #5705. Fixes #2616.)
  • We will emit fewer underconstrained-implicit-instantiation errors, when we decide that using type parameter default or bound won't cause downstream errors.
  • Fixed a bug in LTI where some errors in utility types were not properly shown. Example
  • Fix IDE services that stopped working while a file contained a setter with the wrong number of parameters.
  • Fix an issue with lazy mode where deleting a file before the server starts did not check files that were depending on the deleted file.

Misc:

Parser:

  • Parse bigint object keys (but type checking is not support yet).
flow - https://github.com/facebook/flow/releases/tag/v0.198.2

Published by facebook-github-bot over 1 year ago

Notable bug fixes:

  • Fix a crash on Windows
  • Fix a bug that could possibly result in a crash

Parser:

  • Fix bugs concerning await in async formal parameters (including a regression in 0.198.0)
flow - https://github.com/facebook/flow/releases/tag/v0.198.1

Published by facebook-github-bot over 1 year ago

  • Fix a regression in 0.198.0 that can lead to a crash
flow - https://github.com/facebook/flow/releases/tag/v0.198.0

Published by facebook-github-bot over 1 year ago

Likely to cause new Flow errors:

  • Implicit coercion of booleans to numbers is consistently disallowed. Previously, booleans could be implicitly coerced to numbers in addition expressions. Prefer explicitly converting booleans to numbers.
  • Binary arithmetic errors are now reported on the expression rather than the operands, and use error code unsafe-arithmetic.
  • keyof, undefined, never, unknown, and readonly are now reserved types. If you have a user-defined types of these names, rename them to something else.

New Features:

  • TypeScript syntax helpers. To help people familiar with TypeScript syntax ramp up on similar Flow syntax:
    • Parse and error on keyof type operator, recommending $Keys<...> instead.
    • Parse and error on undefined type, recommending void instead.
    • Parse and error on never type, recommending empty instead.
    • Parse and error on unknown type, recommending mixed instead.
    • Parse and error on readonly applied to tuple and array type syntax.
    • Parse and error on usage of in/out/in out variance annotations.
    • Parse and error on as, as const, and satisfies cast expressions.
  • Add a codemod to fix underconstrained-implicit-instantiation errors only detectable under LTI. You can run flow codemod annotate-implicit-instantiations --include-lti --ignore-suppressed --write .

Notable bug fixes:

  • Fix a bug in LTI mode where some errors were hidden in implicit instantiation calls (e.g. Try Flow)
  • Fix unsound behavior of sentinel refinement with unions of numeric types as tags (e.g. Try Flow)
  • No annotation is required in LTI for callback parameters when the callee is a refined object member (e.g. Try Flow)

IDE:

  • When typing in an object literal, entire method signatures from the object type will be suggested.
  • Method signature autocomplete items are now visually distinguished from other kinds of autocomplete items.
  • Fix manually triggering autocomplete on the last empty line of a file giving no results.
  • Members from Object.prototype are no longer included in autocomplete results.

Parser:

  • Fix parsing of for await (async of ...) (regressed in 0.197.0)
  • Fix parsing of for (let in x) in non-strict mode
  • Fix parsing of class fields named static
  • Fix missing parse errors on keywords containing escape sequences (regressed in 0.180.0)
  • Fix missing parse error when using await as a parameter in an async arrow function
  • Fix missing parse error for export { ReservedWord as ... }
  • Fix incorrect parse error on export * as ReservedWord from ..., which is now allowed
  • Treat && and || as tokens when parsing types to improve error messages
  • Parse the argument of the typeof type argument as a value, not a type, as it is a value

Library Definitions:

  • Add Element.getAttributeNames(): Array<string>
flow - https://github.com/facebook/flow/releases/tag/v0.197.0

Published by facebook-github-bot almost 2 years ago

Local Type Inference:

We are releasing a new inference mode called local type inference. You can enable this new mode in your codebase by adding inference_mode=lti to the [options] section in the flowconfig. We will describe more details on this inference mode in an upcoming blog post.

Likely to cause new Flow errors:

  • Unannotated class properties initialized with null will now errors.
  • We now require all generic functions to be fully annotated.
  • bool is a deprecated alias for boolean. Added a deprecated-type-bool lint and flow fix --error-codes deprecated-type codemod to help migrate to boolean. This lint is also included in the deprecated-type lint; if deprecated-type is enabled, you can opt out with deprecated-type-bool=off

New Features:

  • Tuple improvements:
    • $ReadOnly utility makes tuples read-only. E.g. $ReadOnly<[string, number]> is the same as [+a: string, +b: number].
    • Tuple elements can now have their variance annotated, when the element is labeled. E.g. type T = [+foo: number, +bar: string] creates a read-only tuple.
    • You can now label tuple elements (like TypeScript allows). The labels have no type-checking effect, they just help with self documentation (like indexer labels). When a function argument rest element is a tuple type, the labels work like parameter names in signature help.
    • We now parse tuple spread elements, but type checking of this feature is still unsupported.
    • These new features are now supported in Flow, but we have not upgraded related tools yet. For example, Prettier won't be able to format your code that uses variance annotations on tuples.
  • Allow mixed or any as an annotation to a catch parameter (but not anything else)
  • When typing in a class body, method signatures from super classes and interfaces will be suggested to make overriding/implementing these methods easier.

Notable bug fixes:

  • Improve the parser's error recovery when in the middle of adding type parameters.
  • Trigger autocomplete in JSX tags, JSX attribute values, and private class fields.
  • Improves performance of bigints in big union checks

Misc:

  • Inferred recursive types are shown as any (instead of V$n) in hover types.

Parser:

  • symbol is now a reserved type
  • for (async of []) is now a parse error

Library Definitions:

  • Updated AbortController and AbortSignal signatures
  • Actually expose ReactSetStateFunction type introduced in the last release.
flow - v0.196.3

Published by facebook-github-bot almost 2 years ago

  • Fix a bug that could cause IDE commands to fail while a recheck is ongoing
flow - https://github.com/facebook/flow/releases/tag/v0.196.2

Published by facebook-github-bot almost 2 years ago

🎁 This is (hopefully) our last release of the year. Happy holidays! 🎁

  • Improve performance when unions flow to intersections
  • Fix a crash when using the experimental saved_state.allow_reinit option
flow - https://github.com/facebook/flow/releases/tag/v0.196.1

Published by facebook-github-bot almost 2 years ago

  • Fix some missing autocomplete results (regression in 0.196.0)
flow - https://github.com/facebook/flow/releases/tag/v0.196.0

Published by facebook-github-bot almost 2 years ago

Likely to cause new Flow errors:

  • Instead of mixed, type the result of Object.values and Object.entries on a dictionary to be the dictionary values, and Object.entries keys to behave like Object.keys. Closes #2174, #2221, #4771, #4997, #5838.
  • Ban array inputs to Object.values and Object.entries.
  • Function's name and length property are now not writable.
  • Fix Object.keys, $Values, and $Keys on interfaces with indexers.
  • Delete $Subtype and $SuperType utilities.
  • Delete deprecated-utility Flow lint.

New Features:

  • An annotation is no longer required when exporting + expressions (e.g., export default (3 + 3 : number) can now just be export default 3 + 3;).

Notable bug fixes:

  • Fix unary and binary arithmetic operations on bigints being exported/imported across modules as any or number.
  • Fix autocomplete of string literals in bracket syntax, after a quote has already been typed.
  • Improve sorting of results when autocompleting types.
  • Boolean CLI flags must now be 1 or true to be truthy. Before, anything other than 0 and false was considered truthy.

Misc:

  • Autocomplete results are now sorted case-insensitively.
  • Autocomplete results are now sorted using a fuzzy score, in the same manner as VSCode.

Library Definitions:

  • Add ReactSetStateFunction type alias in react. This is the type of setVal in const [val, setVal] = React.useState(...).
flow - https://github.com/facebook/flow/releases/tag/v0.195.2

Published by facebook-github-bot almost 2 years ago

Misc:

  • Adds an --experimental.run-post-inference-implicit-instantiation true/false CLI flag
    to override the respective experimental flowconfig option.
flow - https://github.com/facebook/flow/releases/tag/v0.195.1

Published by facebook-github-bot almost 2 years ago

Misc:

  • Improved performance for the experimental post-inference implicit instantiation checks.
flow - https://github.com/facebook/flow/releases/tag/v0.195.0

Published by facebook-github-bot almost 2 years ago

  • Add a quick fix for the unused-promise-in-async-scope lint which will insert void.
  • Add symbol and bigint to $NotNullOrVoid
  • Add findLast to Array definition
flow - https://github.com/facebook/flow/releases/tag/v0.194.0

Published by facebook-github-bot almost 2 years ago

Likely to cause new Flow errors:

  • Casting an enum to empty will now properly error, e.g. (E.A: empty).

New Features:

  • Added a quick fix for the unused-promise-in-async-scope lint which will insert await.
  • Added support for a number of additional bigint features. These include allowing comparison (<, >, <=, >=), update (++, --) and arithmetic operators (+, -, ~, *) to be used with bigints.
  • Added sketchy-null-bigint lint to match the behavior of the other sketchy-null-* lints for bigints.
  • Added Flow Enums support for declare enum and declare export enum. Keep in mind that users need to have enabled Flow Enums if you wish to create library definitions that use them.

Parser:

  • Switch to dune to build and install the flow_parser OPAM package. Some modules in src/parser/ like Comment_utils are newly available.
  • Decrease the size of flow_parser.js by roughly 25%, to 768kb.
  • Fix a bug where declare opaque type was parsed as an OpaqueType when interned comments are disabled.
flow - https://github.com/facebook/flow/releases/tag/v0.193.0

Published by facebook-github-bot almost 2 years ago

New Features:

  • Add support for bigint. This includes the bigint type itself, subtyping with literals, libdefs, typeof, and sentinel refinement. For now, literal types are limited to 64 bit ints. Later changes may lift this restriction as well as implement support for operators.

Notable bug fixes:

  • Fix a few bugs related to the Haste package resolver. The Haste resolver falls back to the Node resolver when resolving packages. It now obeys the module.system.node.root_relative_dirname setting when doing so. Also, scoped package names are now supported in the Haste module resolver.
  • Allow private readonly properties to be written to in constructors, just like regular readonly properties.

Misc:

  • Update team members in CONTRIBUTING.md.
  • When using module.system=haste, importing packages in node_modules folders now obeys Node's resolution algorithm, rather than being able to be required from anywhere in the project.

Library Definitions:

  • Add a default generic value for getOwnPropertyDescriptor.
flow - v0.192.0

Published by facebook-github-bot almost 2 years ago

Notable changes:

Likely to cause new Flow errors:

  • Unknown computed properties assignments are now completely banned. Previously, they were still allowed if the object is inexact.
  • cannot-resolve-name errors now are emitted for every use of an undefined variable, not just the first.

New Features:

  • Added an experimental flow lint for unused promises in async scope. You can enable it by adding unused-promise-in-async-scope in the lint section of your flowconfig.

Misc:

  • annotate-use-state and annotate-use-callback codemod commands have been merged into annotate-react-hooks4
  • Added an experimental "scm" saved state fetcher, which selects a saved state based on your currently source control revision.

Library Definitions:

  • Added support for Array.prototype.at
  • Fixed WeakSet type parameter bound to be interface {}