-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Flow implemented class fields while they were very early-stage, behind the `esproposal.class_instance_fields` and `esproposal.class_static_fields` flowconfig options. In current versions of the proposal, fields without initializers now default to `undefined`: [[design](https://github.com/tc39/proposal-class-fields#fields-without-initializers-are-set-to-undefined)] [[spec](https://tc39.es/proposal-class-fields/#sec-define-field)] Babel < 8 stripped uninitialized fields, which is not spec-compliant. Babel 8 changes to leaving the field and just removing the annotation, as you'd rightly expect, but making it impossible* to have type-only fields. [[babel issue](babel/babel#10039)] [[babel 8 notes](babel/babel#10746)] This diff introduces a `declare` syntax to provide a solution for type-only fields: ``` class C { declare foo: string; bar: string; } // becomes class C { bar; } ``` As far as Flow is concerned, both `foo` and `bar` are treated as before, as if they are `string`: ``` const x = new C; (x.foo: string); (x.bar: string); ``` Fixes #6811 [* technically you can use Flow comment syntax -- `class C { /*:: prop: string; */ }` but we don't want to require that] Reviewed By: samwgoldman Differential Revision: D20088452 fbshipit-source-id: f00299539c9387a55102e9a4e554a3b3bcb3498e
- Loading branch information
1 parent
e68dd26
commit 11b7adb
Showing
33 changed files
with
765 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
packages/flow-remove-types/test/expected-pretty-inlinemap-stdin.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.