Skip to content

Commit

Permalink
feat: support spead types
Browse files Browse the repository at this point in the history
  • Loading branch information
halbgut authored and tmcw committed Dec 17, 2018
1 parent 6e74050 commit b4d7c27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions __tests__/lib/flow_doctrine.js
Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion src/flow_doctrine.js
Expand Up @@ -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
Expand Down Expand Up @@ -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)
};
}

Expand Down

0 comments on commit b4d7c27

Please sign in to comment.