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

Correctly parse partial objects with optional value #44304

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ inline JS::NativeOptionalObjectTurboModule::Constants::Builder::Builder(Constant
inline NSString *JS::NativePartialAnnotationTurboModule::SpecGetSomeObjFromPartialSomeObjValue::a() const
{
id const p = _v[@\\"a\\"];
return RCTBridgingToOptionalString(p);
return RCTBridgingToString(p);
}
inline std::optional<bool> JS::NativePartialAnnotationTurboModule::SpecGetSomeObjFromPartialSomeObjValue::b() const
{
Expand All @@ -1211,7 +1211,7 @@ inline std::optional<bool> JS::NativePartialAnnotationTurboModule::SpecGetSomeOb
inline NSString *JS::NativePartialAnnotationTurboModule::SpecGetPartialPartialValue1::a() const
{
id const p = _v[@\\"a\\"];
return RCTBridgingToOptionalString(p);
return RCTBridgingToString(p);
}
inline std::optional<bool> JS::NativePartialAnnotationTurboModule::SpecGetPartialPartialValue1::b() const
{
Expand All @@ -1221,7 +1221,7 @@ inline std::optional<bool> JS::NativePartialAnnotationTurboModule::SpecGetPartia
inline NSString *JS::NativePartialAnnotationTurboModule::SpecGetPartialPartialValue2::a() const
{
id const p = _v[@\\"a\\"];
return RCTBridgingToOptionalString(p);
return RCTBridgingToString(p);
}
inline std::optional<bool> JS::NativePartialAnnotationTurboModule::SpecGetPartialPartialValue2::b() const
{
Expand Down Expand Up @@ -2553,7 +2553,7 @@ inline JS::NativeOptionalObjectTurboModule::Constants::Builder::Builder(Constant
inline NSString *JS::NativePartialAnnotationTurboModule::SpecGetSomeObjFromPartialSomeObjValue::a() const
{
id const p = _v[@\\"a\\"];
return RCTBridgingToOptionalString(p);
return RCTBridgingToString(p);
}
inline std::optional<bool> JS::NativePartialAnnotationTurboModule::SpecGetSomeObjFromPartialSomeObjValue::b() const
{
Expand All @@ -2563,7 +2563,7 @@ inline std::optional<bool> JS::NativePartialAnnotationTurboModule::SpecGetSomeOb
inline NSString *JS::NativePartialAnnotationTurboModule::SpecGetPartialPartialValue1::a() const
{
id const p = _v[@\\"a\\"];
return RCTBridgingToOptionalString(p);
return RCTBridgingToString(p);
}
inline std::optional<bool> JS::NativePartialAnnotationTurboModule::SpecGetPartialPartialValue1::b() const
{
Expand All @@ -2573,7 +2573,7 @@ inline std::optional<bool> JS::NativePartialAnnotationTurboModule::SpecGetPartia
inline NSString *JS::NativePartialAnnotationTurboModule::SpecGetPartialPartialValue2::a() const
{
id const p = _v[@\\"a\\"];
return RCTBridgingToOptionalString(p);
return RCTBridgingToString(p);
}
inline std::optional<bool> JS::NativePartialAnnotationTurboModule::SpecGetPartialPartialValue2::b() const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe('FlowParser', () => {
const expected = [
{
name: 'a',
optional: true,
optional: false,
typeAnnotation: {type: 'StringTypeAnnotation'},
},
{
Expand Down Expand Up @@ -623,7 +623,7 @@ describe('TypeScriptParser', () => {
const expected = [
{
name: 'a',
optional: true,
optional: false,
typeAnnotation: {properties: [], type: 'ObjectTypeAnnotation'},
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1760,7 +1760,7 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_PARTIALS
'properties': [
{
'name': 'a',
'optional': true,
'optional': false,
'typeAnnotation': {
'type': 'StringTypeAnnotation'
}
Expand Down Expand Up @@ -1795,7 +1795,7 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_PARTIALS
'properties': [
{
'name': 'a',
'optional': true,
'optional': false,
'typeAnnotation': {
'type': 'StringTypeAnnotation'
}
Expand Down Expand Up @@ -1868,7 +1868,7 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_PARTIALS
'properties': [
{
'name': 'a',
'optional': true,
'optional': false,
'typeAnnotation': {
'type': 'StringTypeAnnotation'
}
Expand All @@ -1891,7 +1891,7 @@ exports[`RN Codegen Flow Parser can generate fixture NATIVE_MODULE_WITH_PARTIALS
'properties': [
{
'name': 'a',
'optional': true,
'optional': false,
'typeAnnotation': {
'type': 'StringTypeAnnotation'
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-codegen/src/parsers/flow/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class FlowParser implements Parser {
return properties.map(prop => {
return {
name: prop.key.name,
optional: true,
optional: prop?.optional ?? false,
typeAnnotation: flowTranslateTypeAnnotation(
hasteModuleName,
prop.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,7 @@ exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_PA
'properties': [
{
'name': 'a',
'optional': true,
'optional': false,
'typeAnnotation': {
'type': 'StringTypeAnnotation'
}
Expand Down Expand Up @@ -2261,7 +2261,7 @@ exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_PA
'properties': [
{
'name': 'a',
'optional': true,
'optional': false,
'typeAnnotation': {
'type': 'StringTypeAnnotation'
}
Expand Down Expand Up @@ -2334,7 +2334,7 @@ exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_PA
'properties': [
{
'name': 'a',
'optional': true,
'optional': false,
'typeAnnotation': {
'type': 'StringTypeAnnotation'
}
Expand All @@ -2357,7 +2357,7 @@ exports[`RN Codegen TypeScript Parser can generate fixture NATIVE_MODULE_WITH_PA
'properties': [
{
'name': 'a',
'optional': true,
'optional': false,
'typeAnnotation': {
'type': 'StringTypeAnnotation'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ class TypeScriptParser implements Parser {
return properties.map(prop => {
return {
name: prop.key.name,
optional: true,
optional: prop?.optional ?? false,
typeAnnotation: typeScriptTranslateTypeAnnotation(
hasteModuleName,
prop.typeAnnotation.typeAnnotation,
Expand Down