Array's with unparsable element type's are explicitly Any vs missing (#46221)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46221

Previously the schema special cased unparseable elementType with elementType just being undefined. This causes issues for logic that requires recursively matching types. Instead of being implicit, this makes them explicitly an AnyTypeAnnotation

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D61825742

fbshipit-source-id: 47bf70d32d21647896d8f5319087378cc8ac8d4f
This commit is contained in:
Eli White
2024-08-29 10:51:31 -07:00
committed by Facebook GitHub Bot
parent 0f66a696b4
commit 0b56ccab2a
13 changed files with 154 additions and 80 deletions
@@ -93,9 +93,12 @@ class StructCollector {
});
}
case 'ArrayTypeAnnotation': {
if (typeAnnotation.elementType == null) {
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
return wrapNullable(nullable, {
type: 'ArrayTypeAnnotation',
elementType: {
type: 'AnyTypeAnnotation',
},
});
}
@@ -118,7 +118,7 @@ function toObjCType(
case 'GenericObjectTypeAnnotation':
return wrapObjCOptional('id<NSObject>', isRequired);
case 'ArrayTypeAnnotation':
if (typeAnnotation.elementType == null) {
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
return wrapObjCOptional('id<NSObject>', isRequired);
}
@@ -198,7 +198,7 @@ function toObjCValue(
return value;
case 'ArrayTypeAnnotation':
const {elementType} = typeAnnotation;
if (elementType == null) {
if (elementType.type === 'AnyTypeAnnotation') {
return value;
}
@@ -109,7 +109,7 @@ function toObjCType(
case 'GenericObjectTypeAnnotation':
return wrapObjCOptional('id<NSObject>', isRequired);
case 'ArrayTypeAnnotation':
if (typeAnnotation.elementType == null) {
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
return wrapObjCOptional('id<NSObject>', isRequired);
}
return wrapCxxOptional(
@@ -188,7 +188,7 @@ function toObjCValue(
return value;
case 'ArrayTypeAnnotation':
const {elementType} = typeAnnotation;
if (elementType == null) {
if (elementType.type === 'AnyTypeAnnotation') {
return value;
}
@@ -305,7 +305,7 @@ function getReturnObjCType(
case 'TypeAliasTypeAnnotation':
return wrapOptional('NSDictionary *', isRequired);
case 'ArrayTypeAnnotation':
if (typeAnnotation.elementType == null) {
if (typeAnnotation.elementType.type === 'AnyTypeAnnotation') {
return wrapOptional('NSArray<id<NSObject>> *', isRequired);
}