diff --git a/__tests__/lib/flow_doctrine.js b/__tests__/lib/flow_doctrine.js index 45ae1b7a5..88e2f63da 100644 --- a/__tests__/lib/flow_doctrine.js +++ b/__tests__/lib/flow_doctrine.js @@ -300,6 +300,11 @@ test('flowDoctrine', function() { name: 'this' }); + expect(toDoctrineType('{ ...A }')).toEqual({ + fields: [], + type: 'RecordType' + }); + // TODO: remove all these types expect(types).toEqual([ 'ExistsTypeAnnotation', diff --git a/src/flow_doctrine.js b/src/flow_doctrine.js index f69465217..9be259902 100644 --- a/src/flow_doctrine.js +++ b/src/flow_doctrine.js @@ -14,6 +14,8 @@ const oneToOne = { }; function propertyToField(property) { + if (!property.value) return null; + let type = flowDoctrine(property.value); if (property.optional) { // Doctrine does not support optional fields but it does have something called optional types @@ -125,7 +127,7 @@ function flowDoctrine(type) { if (type.properties) { return { type: 'RecordType', - fields: type.properties.map(propertyToField) + fields: type.properties.map(propertyToField).filter(x => x) }; }