Skip to content

Turbo module codegen support interface with inheritance in module#36011

Closed
ZihanChen-MSFT wants to merge 6 commits intofacebook:mainfrom
ZihanChen-MSFT:ts-rncodegen18
Closed

Turbo module codegen support interface with inheritance in module#36011
ZihanChen-MSFT wants to merge 6 commits intofacebook:mainfrom
ZihanChen-MSFT:ts-rncodegen18

Conversation

@ZihanChen-MSFT
Copy link
Copy Markdown
Contributor

Summary

The previous pull request 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

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

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

Test Plan

yarn jest react-native-codegen passed

@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 Jan 31, 2023
@analysis-bot
Copy link
Copy Markdown

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,463,544 +134
android hermes armeabi-v7a 7,783,956 +220
android hermes x86 8,936,644 +252
android hermes x86_64 8,794,679 +328
android jsc arm64-v8a 9,648,959 +0
android jsc armeabi-v7a 8,383,226 +0
android jsc x86 9,710,923 +0
android jsc x86_64 10,187,777 +0

Base commit: 8568b93
Branch: main

@facebook-github-bot
Copy link
Copy Markdown
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 Jan 31, 2023
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@cipolleschi merged this pull request in bf34810.

@ZihanChen-MSFT ZihanChen-MSFT deleted the ts-rncodegen18 branch February 13, 2023 22:28
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants