From 8abbe9c67ce829f3c32a9311e1afd756dd5527b2 Mon Sep 17 00:00:00 2001 From: Marshall Roch Date: Thu, 2 Mar 2023 07:28:59 -0800 Subject: [PATCH] v0.201.0 Reviewed By: gkz Differential Revision: D43721373 (https://github.com/facebook/flow/commit/f760a77ea4f038f83301f2b0fea2a62861e74620) ------------------------------------------------------------------------ (from 672b91632cbe0ab53f0468d2936b2a2c3278eaa1) fbshipit-source-id: 15fa2d0b511c55a20077bbf3dbb0121178d5a0aa --- Changelog.md | 47 +++++++++++++++++++++++++ flow_parser.opam | 2 +- flowtype.opam | 4 +-- packages/flow-parser-bin/package.json | 2 +- packages/flow-parser/package.json | 2 +- packages/flow-remove-types/package.json | 4 +-- src/common/flow_version.ml | 2 +- website/docs/install.md | 2 +- 8 files changed, 56 insertions(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index bd0a266626d..5c0eee7422d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,50 @@ +### 0.201.0 + +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](https://medium.com/flow-type/local-type-inference-for-flow-aaa65d071347) 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](https://flow.org/try/#0DYUwLgBAJghmMQLwQEQEYUG4BQBLAZhABRgBOAriAJTRwLJo6zyYQD0bEADqSAG64A9uQDOwAJ4RckAO65gwCAAsYfEBDDiu6gHbkAtgCMQpCAB8IIsrh0BzADQQdgmVNnzFKtRq3qrpG1tsIA) +* 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](https://flow.org/try/#0DYUwLgBAHg3BD08IDsQHcIEtkDcCGwmAJgLREgDGweATnmJgPbIQg02M0BQXAZgK7IKDZhF4AeACoA+ABQBPAFwRJASggBvLhGgQAvBHkwuAXx6hIALy5A) +* 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`](https://www.npmjs.com/package/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 + ### 0.200.1 Notable bug fixes: diff --git a/flow_parser.opam b/flow_parser.opam index 0fb8127bc5c..8efb6c2e4aa 100644 --- a/flow_parser.opam +++ b/flow_parser.opam @@ -1,6 +1,6 @@ opam-version: "2.0" name: "flow_parser" -version: "0.200.1" +version: "0.201.0" maintainer: "flow@fb.com" authors: ["Flow Team "] homepage: "https://github.com/facebook/flow/tree/master/src/parser" diff --git a/flowtype.opam b/flowtype.opam index 9d1c0f7ed71..d22bf5cc157 100644 --- a/flowtype.opam +++ b/flowtype.opam @@ -1,6 +1,6 @@ opam-version: "2.0" name: "flowtype" -version: "0.200.1" +version: "0.201.0" maintainer: "flow@fb.com" authors: "Flow Team " license: "MIT" @@ -15,7 +15,7 @@ depends: [ "core_kernel" {>= "v0.14.1" & < "v0.15.0"} "dtoa" {>= "0.3.2"} "fileutils" {>= "0.6.3"} - "flow_parser" {= "0.200.1"} + "flow_parser" {= "0.201.0"} "inotify" {os = "linux" & >= "2.4.1"} "ounit2" {with-test} "sedlex" {>= "2.3"} diff --git a/packages/flow-parser-bin/package.json b/packages/flow-parser-bin/package.json index 516150bc51d..fd5bbecfddc 100644 --- a/packages/flow-parser-bin/package.json +++ b/packages/flow-parser-bin/package.json @@ -1,6 +1,6 @@ { "name": "flow-parser-bin", - "version": "0.200.1", + "version": "0.201.0", "description": "The Flow JavaScript parser, via bindings to the native OCaml implementation", "main": "index.js", "repository": "https://github.com/facebook/flow.git", diff --git a/packages/flow-parser/package.json b/packages/flow-parser/package.json index 1fa00c824b6..f74e8050cc8 100644 --- a/packages/flow-parser/package.json +++ b/packages/flow-parser/package.json @@ -1,6 +1,6 @@ { "name": "flow-parser", - "version": "0.200.1", + "version": "0.201.0", "description": "JavaScript parser written in OCaml. Produces ESTree AST", "homepage": "https://flow.org", "license": "MIT", diff --git a/packages/flow-remove-types/package.json b/packages/flow-remove-types/package.json index 3274ac5637c..c66285da3a0 100644 --- a/packages/flow-remove-types/package.json +++ b/packages/flow-remove-types/package.json @@ -1,6 +1,6 @@ { "name": "flow-remove-types", - "version": "2.200.1", + "version": "2.201.0", "description": "Removes Flow type annotations from JavaScript files with speed and simplicity.", "author": { "name": "Flow Team", @@ -44,7 +44,7 @@ "es6" ], "dependencies": { - "flow-parser": "^0.200.1", + "flow-parser": "^0.201.0", "pirates": "^3.0.2", "vlq": "^0.2.1" }, diff --git a/src/common/flow_version.ml b/src/common/flow_version.ml index 440a3d90564..d086bbdfb54 100644 --- a/src/common/flow_version.ml +++ b/src/common/flow_version.ml @@ -5,4 +5,4 @@ * LICENSE file in the root directory of this source tree. *) -let version = "0.200.1" +let version = "0.201.0" diff --git a/website/docs/install.md b/website/docs/install.md index 076704fe155..46d47524f2d 100644 --- a/website/docs/install.md +++ b/website/docs/install.md @@ -124,7 +124,7 @@ npm install --save-dev flow-bin "name": "my-flow-project", "version": "1.0.0", "devDependencies": { - "flow-bin": "^0.200.1" + "flow-bin": "^0.201.0" }, "scripts": { "flow": "flow"