-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Turbo module codegen support interface like alias in module #35812
Conversation
Base commit: ac54a5b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good. Just to double-check: do we need something similar with Components also?
I'm thinking about a component with some props like:
interface BaseProps {
sharedProp: number
}
interface iOSProps extends BaseProps {
iOSProp: number
}
interface AndroidProps extends BaseProps {
androidProp: number
}
If we need it, it is fine to add it in a new PR, though.
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cipolleschi merged this pull request in 8befb74. |
@cipolleschi Hi, component doesn't support alias, all interfaces or aliases got inlined into the component. And I remember I've already made interface features available for component before as data types, as a component itself is not tested though. |
Hey Guys, it's released? |
@migueldaipre Nope this will land in 0.72 |
…6011) Summary: The [previous pull request](#35812) enables defining interfaces and using them in a turbo module, but all members are flattened, this is not the best option for codegen for object oriented languages. In this pull request, an optional member `baseTypes` is added to aliased objects. Members are still flattened for backward compatibility, if a codegen doesn't care about that nothing needs to be changed. ### Example ```typescript interface A { a : string; } interface B extends A { b : number; } ``` #### Before the previous pull request `interface` is not allowed here, you must use type alias. #### At the previous pull request `interface` is allowed, but it is translated to ```typescript type A = {a : string}; type B = {a : string, b : number}; ``` #### At this pull request Extra information is provided so that you know `B` extends `A`. By comparing `B` to `A` it is easy to know that `B::a` is obtained from `A`. ## Changelog [GENERAL] [CHANGED] - Turbo module codegen support interface with inheritance in module Pull Request resolved: #36011 Test Plan: `yarn jest react-native-codegen` passed Reviewed By: rshest Differential Revision: D42882650 Pulled By: cipolleschi fbshipit-source-id: 32d502e8a99c4151fae0a1f4dfa60db9ac827963
…#35812) Summary: Turbo module codegen support interface like alias in module. In typescript, interface allows inheritance, but the codegen schema doesn't have such information. In this PR the codegen schema is not changed, interfaces are flattened. In the next change, I will update the codegen schema so that it allows inheritance, in order to generate more precise C++ code. ## Changelog [GENERAL] [CHANGED] - Turbo module codegen support interface like alias in module Pull Request resolved: facebook#35812 Test Plan: `yarn jest react-native-codegen` passed Reviewed By: cortinico Differential Revision: D42475368 Pulled By: cipolleschi fbshipit-source-id: 26025f8a55b600dfea27026c998cd8b5fe752af4
…cebook#36011) Summary: The [previous pull request](facebook#35812) enables defining interfaces and using them in a turbo module, but all members are flattened, this is not the best option for codegen for object oriented languages. In this pull request, an optional member `baseTypes` is added to aliased objects. Members are still flattened for backward compatibility, if a codegen doesn't care about that nothing needs to be changed. ### Example ```typescript interface A { a : string; } interface B extends A { b : number; } ``` #### Before the previous pull request `interface` is not allowed here, you must use type alias. #### At the previous pull request `interface` is allowed, but it is translated to ```typescript type A = {a : string}; type B = {a : string, b : number}; ``` #### At this pull request Extra information is provided so that you know `B` extends `A`. By comparing `B` to `A` it is easy to know that `B::a` is obtained from `A`. ## Changelog [GENERAL] [CHANGED] - Turbo module codegen support interface with inheritance in module Pull Request resolved: facebook#36011 Test Plan: `yarn jest react-native-codegen` passed Reviewed By: rshest Differential Revision: D42882650 Pulled By: cipolleschi fbshipit-source-id: 32d502e8a99c4151fae0a1f4dfa60db9ac827963
Summary
Turbo module codegen support interface like alias in module.
In typescript, interface allows inheritance, but the codegen schema doesn't have such information. In this PR the codegen schema is not changed, interfaces are flattened.
In the next change, I will update the codegen schema so that it allows inheritance, in order to generate more precise C++ code.
Changelog
[GENERAL] [CHANGED] - Turbo module codegen support interface like alias in module
Test Plan
yarn jest react-native-codegen
passed