Skip to content

Conversation

@Pranav-yadav
Copy link
Contributor

@Pranav-yadav Pranav-yadav commented Feb 26, 2023

Summary

Part of Umbrella #34872

[Codegen 84 - assigned to @Pranav-yadav] It depends on [Codegen 83] export the parseModuleName anonymous function (Flow, TypeScript) in a common parseModuleName function in the parsers-commons.js file.

  • merged Parse Module-Name anon fn of Flow & TS parsers; into a common parseModuleName fn in the parsers-commons.js
  • added tests for parseModuleName fn from parsers-commons.js
  • added callExpressionTypeParameters method to parsers
  • added tests for callExpressionTypeParameters method of parsers
  • used parser.callExpressionTypeParameters method in parseModuleName fn

PS: fixed merge conflicts several times :(

Overall :)

Changelog

[INTERNAL] [CHANGED] - Merge Parse-Module-Name anon fn of Flow & TS and add callExpressionTypeParameters method to parsers

Test Plan

  • yarn lint && yarn run flow && yarn test react-native-codegen ==> ✅

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 26, 2023
@analysis-bot
Copy link

analysis-bot commented Feb 26, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,477,095 +0
android hermes armeabi-v7a 7,799,079 +0
android hermes x86 8,953,089 +0
android hermes x86_64 8,810,587 +0
android jsc arm64-v8a 9,108,176 +0
android jsc armeabi-v7a 8,304,844 +0
android jsc x86 9,159,032 +0
android jsc x86_64 9,418,319 +0

Base commit: a49446b
Branch: main

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

@Pranav-yadav, thank you so much and great job!

I left a couple of comments that should be addressed before merging this PR.

Thank you again for the work you are putting into this!

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Let's remove the commented test (see my comment for the why). I'll import and merge the PR.

Thank you for this work!

@Pranav-yadav
Copy link
Contributor Author

Let's remove the commented test (see my comment for the why). I'll import and merge the PR.
Thank you for this work!

aaah... Exactly... I've spent hours debugging it (the generated ASTs 😞) and going through the base test cases but they couldn't help as they use fake manually created ASTs and not the actual one created by parser. PS: was going to add counter for "hours wasted here :(", jk

Thanks. I'll rm that test.

Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

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

Thank you so much for taking care of this!

@facebook-github-bot
Copy link
Contributor

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

@Pranav-yadav
Copy link
Contributor Author

Pranav-yadav commented Mar 1, 2023

I see conflicts again... :(

Rebasing quickly to fix :)
Edit: rebased and fixed

@cipolleschi

- into a common `parseModuleName` fun in the `parsers-commons.js`
- in `parsers-commons-test.js`
- related to: [Codegen 84]
…ror` in `parseModuleName` fn

- reason: The problem here is that;

```flow
export default TurboModuleRegistry.getEnforcing('SampleTurboModule');
```

this result in an `UntypedModuleRegistryCallParserError`, because it is "not generic".

The problem is that, to get a type for it, it "must" be a generic.
I can't think of any other way for `getEnforcing` to be typed with a different type rather than generic. 🤔

I don't think there is a way to create a valid Flow code which is typed with something that is not a generic.
I looked at the base test for that throw and they are manually creating an AST that satisfy that requirement,
but that AST probably can't be actually generated. 🤔

-- @cipolleschi
@Pranav-yadav Pranav-yadav force-pushed the codegen-84-parseModuleName branch from aa19750 to 2b6a831 Compare March 1, 2023 16:40
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Mar 2, 2023
@facebook-github-bot
Copy link
Contributor

@cipolleschi merged this pull request in 05454fa.

@Pranav-yadav Pranav-yadav deleted the codegen-84-parseModuleName branch March 2, 2023 17:04
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
…#36297)

Summary:
Part of Umbrella facebook#34872
> [**Codegen 84** - assigned to Pranav-yadav] It depends on [Codegen 83] export the parseModuleName anonymous function (Flow, TypeScript) in a common parseModuleName function in the parsers-commons.js file.

- merged Parse Module-Name _**anon**_ fn of `Flow` & `TS` parsers; into a common `parseModuleName` fn in the `parsers-commons.js`
- added **tests** for `parseModuleName` fn from `parsers-commons.js`
- added `callExpressionTypeParameters` method to **_parsers_**
- added **tests** for `callExpressionTypeParameters` method of _parsers_
- used `parser.callExpressionTypeParameters` method in `parseModuleName` fn

PS: fixed merge conflicts several times :(

Overall :)

## Changelog

[INTERNAL] [CHANGED] - Merge Parse-Module-Name anon fn of `Flow` & `TS` and add `callExpressionTypeParameters` method to **_parsers_**

Pull Request resolved: facebook#36297

Test Plan: - `yarn lint && yarn run flow && yarn test react-native-codegen`  ==> ✅

Reviewed By: rshest

Differential Revision: D43694563

Pulled By: cipolleschi

fbshipit-source-id: 99cf40ada0a567cd9ff91078f66fd4ac3684f7cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants