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

Recognize dictionary type in codegen #37206

Closed
wants to merge 6 commits into from

Conversation

ZihanChen-MSFT
Copy link
Contributor

Summary

Previously we allow {[key:string]:Something} in codegen, Something is type-checked but thrown away, generating a GenericObjectTypeAnnotation.
In this change, Something is added to GenericObjectTypeAnnotation as an optional field.
For downstream code such as C++ codegen, this change is backward compatible. It allows C++ codegen to produce a more precious type optionally.

Changelog:

[General] [Added] - Recognize dictionary type in codegen

Test Plan

yarn jest react-native-codegen
yarn jest react-native-codegen-typescript-test

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Microsoft Partner: Microsoft Partner labels May 2, 2023
@analysis-bot
Copy link

analysis-bot commented May 2, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,628,252 -362
android hermes armeabi-v7a 7,940,459 -250
android hermes x86 9,115,071 -525
android hermes x86_64 8,969,776 -430
android jsc arm64-v8a 9,192,170 -604
android jsc armeabi-v7a 8,381,829 -500
android jsc x86 9,250,349 -764
android jsc x86_64 9,508,692 -663

Base commit: 1be65ba
Branch: main

@dmytrorykun
Copy link
Contributor

@ZihanChen-MSFT thanks for the PR! Could you please address the linter warnings.

@Pranav-yadav Pranav-yadav added the Tech: Codegen Related to react-native-codegen label May 3, 2023
@facebook-github-bot
Copy link
Contributor

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

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.

Thanks @ZihanChen-MSFT for doing this.
This is a good first step! It adds dictionary to NativeModules only but it provides a guide guidance on how to add this in components too (props, events and commands)

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

@dmytrorykun merged this pull request in 4fd8f40.

jeongshin pushed a commit to jeongshin/react-native that referenced this pull request May 7, 2023
Summary:
Previously we allow `{[key:string]:Something}` in codegen, `Something` is type-checked but thrown away, generating a `GenericObjectTypeAnnotation`.
In this change, `Something` is added to `GenericObjectTypeAnnotation` as an optional field.
For downstream code such as C++ codegen, this change is **backward compatible**. It allows C++ codegen to produce a more precious type optionally.

## Changelog:

[General] [Added] - Recognize dictionary type in codegen

Pull Request resolved: facebook#37206

Test Plan:
```
yarn jest react-native-codegen
yarn jest react-native-codegen-typescript-test
```

Reviewed By: cipolleschi

Differential Revision: D45563340

Pulled By: dmytrorykun

fbshipit-source-id: 9a9ce36df6ded6d42d35c3dcb6fb0eaca16c4458
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. p: Microsoft Partner: Microsoft Partner Tech: Codegen Related to react-native-codegen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants