Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Member and TypeCast expressions in super class types #1408

Closed
wants to merge 1 commit into from

Conversation

xleoooo
Copy link
Contributor

@xleoooo xleoooo commented May 23, 2024

Summary

Previously, member expressions in parent classes like class A extends Foo.Bar, and type casts such as class A extends (Foo: Bar), were not parseable by flow-api-translator. This change adds support.

Test Plan

Previously unparseable files in react-native are now parseable

@facebook-github-bot
Copy link
Contributor

Hi @xleoooo!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@tmikov tmikov requested a review from pieterv May 23, 2024 22:53
Copy link
Member

@pieterv pieterv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the inline comments please add test cases.

I'm also curious what you are using this tool chain for?

@xleoooo xleoooo requested a review from pieterv May 30, 2024 23:53
@xleoooo
Copy link
Contributor Author

xleoooo commented May 31, 2024

Still working on those test cases, I'm having some trouble with jest, but was hoping to get a review on the source changes in the meantime.

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

Copy link
Member

@huntie huntie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with nits to action. cc @pieterv

I've run this against the existing test suite (with jest --watch) and the affected tests all pass. Just to check: @xleoooo you've observed this produces an end-to-end fix?

image

@huntie huntie marked this pull request as ready for review June 5, 2024 18:37
@xleoooo
Copy link
Contributor Author

xleoooo commented Jun 11, 2024

Just to check: @xleoooo you've observed this produces an end-to-end fix?

yes, with some small caveat: some of the current RN source isn't valid input.

class FileReader extends (EventTarget(...READER_EVENTS): any) {}

AFAIK this is valid flow source code, but neither of the following typedefs are OK based on flow playground

declare class FileReader extends any {}
declare class FileReader extends (EventTarget(...READER_EVENTS): any) {}

So, for type cast super classes, they are only valid for flowToFlowDef if cast to Identifier. This means we'll still need to add our own typings for EventTarget, instead of casting any.

@xleoooo xleoooo force-pushed the flow-api-parser-improvements branch 2 times, most recently from 398eafb to c999d49 Compare June 11, 2024 03:02
@huntie huntie dismissed pieterv’s stale review June 13, 2024 15:04

Feedback actioned

@xleoooo xleoooo force-pushed the flow-api-parser-improvements branch from c999d49 to 892decf Compare June 13, 2024 17:22
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Jun 13, 2024
@facebook-github-bot
Copy link
Contributor

@huntie has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@xleoooo xleoooo force-pushed the flow-api-parser-improvements branch from 892decf to e26c61b Compare June 19, 2024 03:29
@facebook-github-bot
Copy link
Contributor

@xleoooo has updated the pull request. You must reimport the pull request before landing.

Summary: Previously, member expressions in parent classes like `class A
extends Foo.Bar`, and type casts such as `class A extends (Foo: typeof Bar)`,
were not parseable by flow-api-translator. This change adds support.
@xleoooo xleoooo force-pushed the flow-api-parser-improvements branch from e26c61b to c6a37ed Compare June 19, 2024 04:12
@facebook-github-bot
Copy link
Contributor

@xleoooo has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@huntie has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@huntie merged this pull request in 14d3201.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants