Skip to content

Commit ca5a681

Browse files
halbguttmcw
authored andcommitted
feat: support spead types
1 parent 6e74050 commit ca5a681

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

__tests__/lib/flow_doctrine.js

+5
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ test('flowDoctrine', function() {
300300
name: 'this'
301301
});
302302

303+
expect(toDoctrineType('{ ...A }')).toEqual({
304+
fields: [],
305+
type: 'RecordType'
306+
});
307+
303308
// TODO: remove all these types
304309
expect(types).toEqual([
305310
'ExistsTypeAnnotation',

src/flow_doctrine.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const oneToOne = {
1414
};
1515

1616
function propertyToField(property) {
17+
if (!property.value) return null;
18+
1719
let type = flowDoctrine(property.value);
1820
if (property.optional) {
1921
// Doctrine does not support optional fields but it does have something called optional types
@@ -125,7 +127,7 @@ function flowDoctrine(type) {
125127
if (type.properties) {
126128
return {
127129
type: 'RecordType',
128-
fields: type.properties.map(propertyToField)
130+
fields: type.properties.map(propertyToField).filter(x => x)
129131
};
130132
}
131133

0 commit comments

Comments
 (0)