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

[compiler][ez] Fix reanimated custom type defs for imports #31137

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

mofeiZ
Copy link
Contributor

@mofeiZ mofeiZ commented Oct 7, 2024

When we added support for Reanimated, we didn't distinguish between true globals (i.e. identifiers with no static resolutions), module types, and imports #29188. For the past 3-4 months, Reanimated imports were not being matched to the correct hook / function shape we match globals and module imports against two different registries.

This PR fixes our support for Reanimated library functions imported under react-native-reanimated. See test fixtures for details

Copy link

vercel bot commented Oct 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 7, 2024 5:05pm

Comment on lines 691 to 695
installReAnimatedTypes(
this.#moduleTypes,
this.#shapes,
REANIMATED_MODULE_NAME,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Subtle design feedback here, but it's generally better to avoid mutating functions if possible. In this case, instead of installReanimatedTypes() this could be buildReanimatedTypes() which returns the same data type as moduleTypeResolver, and which we then install.

Alternatively, we could just pass #shapes and then return a type, which the caller (here) adds to moduleTypes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Thanks for the feedback

Copy link
Contributor

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

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

Awesome! See comment for a small design tweak but thank you for fixing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants