-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Support TypeScript array types for turbo module (module only) #34183
Conversation
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.
Thanks @ZihanChen-MSFT for the PR.
Left a comment to clarify a line.
Overall, it looks good to me. Many thanks for the tests also!
aliasMap, | ||
cxxOnly, | ||
'ReadonlyArray', | ||
typeAnnotation.typeAnnotation.elementType, |
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.
Is this correct? I can can see in the previous case that the line was just typeAnnotation.elementType
instead of typeAnnotation.typeAnnotation.elementType
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.
This is intended.
For T[]
, it is a TSArrayType
on a TSTypeReference
.
For readonly T[]
, it is a TSTypeOperator
on a TSArrayType
on a TSTypeReference
.
This is why it has one more .typeAnnotation
.
And this should be proven by the unit test, since I copied Array<T>
test cases to T[]
(same for readonly), and copied snapshots, it ensures that Array<T>
case and T[]
case provide exactly the same output.
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
This pull request was successfully merged by @ZihanChen-MSFT in f0c4c29. When will my fix make it into a release? | Upcoming Releases |
Summary
Turbo module codegen supports arrays in both Flow and TypeScript, but it only recognize
Array<T>
andReadonlyArray<T>
in TypeScript.In this change,
T[]
andreadonly T[]
are made recognizable in codegen.Changelog
[General] [Added] - Support TypeScript array types for turbo module (module only)
Test Plan
yarn jest
passed inpackages/react-native-codegen