Add support for spread with ReadOnlyArray

Summary: The new support for ReadOnlyArray needs to call this new function for spreads too.

Reviewed By: JoshuaGross

Differential Revision: D16823796

fbshipit-source-id: 9de94b41cdead7ce5238c77a9e39b5daf760dfe2
This commit is contained in:
Eli White 2019-08-15 11:25:45 -07:00 коммит произвёл Facebook Github Bot
Родитель c8b9a3f8e2
Коммит 6c3b01d07f
3 изменённых файлов: 44 добавлений и 3 удалений

Просмотреть файл

@ -490,6 +490,8 @@ export type ModuleProps = $ReadOnly<{|
localType: $ReadOnly<{|
...PropsInFile
|}>
localArr: $ReadOnlyArray<PropsInFile>
|}>;
export default (codegenNativeComponent<ModuleProps>(

Просмотреть файл

@ -5515,6 +5515,42 @@ Object {
"type": "ObjectTypeAnnotation",
},
},
Object {
"name": "localArr",
"optional": false,
"typeAnnotation": Object {
"elementType": Object {
"properties": Array [
Object {
"name": "otherStringProp",
"optional": false,
"typeAnnotation": Object {
"default": null,
"type": "StringTypeAnnotation",
},
},
Object {
"name": "isEnabled",
"optional": false,
"typeAnnotation": Object {
"default": false,
"type": "BooleanTypeAnnotation",
},
},
Object {
"name": "label",
"optional": false,
"typeAnnotation": Object {
"default": null,
"type": "StringTypeAnnotation",
},
},
],
"type": "ObjectTypeAnnotation",
},
"type": "ArrayTypeAnnotation",
},
},
],
},
},

Просмотреть файл

@ -50,9 +50,12 @@ function getTypeAnnotationForArray(name, typeAnnotation, defaultValue, types) {
if (objectType.id.name === '$ReadOnly') {
return {
type: 'ObjectTypeAnnotation',
properties: objectType.typeParameters.params[0].properties.map(prop =>
buildPropSchema(prop, types),
),
properties: flattenProperties(
objectType.typeParameters.params[0].properties,
types,
)
.map(prop => buildPropSchema(prop, types))
.filter(Boolean),
};
}
}