Skip to content

Should not remove class fields when using flow #10039

@nicolo-ribaudo

Description

@nicolo-ribaudo

If the flow plugin runs before the class properties one (or if the class properties plugin isn't used), we remove uninitialize class fields:

class Foo { x: string }

currently becomes

class Foo {}

while it should be

class Foo { x }

If someone still wants the old behavior, they can either use flow comments (as offically recommended), or use the ignoreUninitialized option which will soon be added to the class properties plugin (#9141).


Is there anyone who wants to contribute for the first time to Babel? 🙂

NOTE ⚠️⚠️⚠️ Since this is a breaking change, we won't merge the PR for a long time (before Babel 8), and it might seem that we are ignoring it.

If you don't know how to clone Babel, follow these steps: (you need to have make and yarn available on your machine).

  1. Write a comment there to know other possible contributors that you are working on this bug.
  2. Fork the repo
  3. Run git clone https://github.com/<YOUR_USERNAME>/babel.git && cd babel
  4. Run yarn && make bootstrap
  5. Wait ⏳
  6. Run make watch (or make build whenever you change a file)
  7. Change the wrong output.js files in the tests/fixture folder of @babel/plugin-transform-flow-strip-types (if there are any)
  8. Update the code!
  9. yarn jest [name-of-the-package-to-test] to run the tests
    • If some test outputs don't match but the new results are correct, you can delete the bad output.js files and run the tests again
  10. If it is working, run make test tu run all the tests
  11. Run git push and open a PR!

Metadata

Metadata

Assignees

Labels

Has PRclaimedgood first issueoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions