Skip to content

Commit

Permalink
fix: special property names in flowtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtnbroder authored and tmcw committed Sep 14, 2017
1 parent a820174 commit 7fc6ca8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/flow_doctrine.js
Expand Up @@ -27,7 +27,7 @@ function propertyToField(property) {
}
return {
type: 'FieldType',
key: property.key.name,
key: property.key.name || property.key.value,
value: type
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/infer/params.js
Expand Up @@ -197,8 +197,8 @@ function paramToDoc(
});
}
case 'ObjectProperty': {
return _.assign(paramToDoc(param.value, prefix + '.' + param.key.name), {
name: prefix + '.' + param.key.name
return _.assign(paramToDoc(param.value, prefix + '.' + param.key.name || param.key.value), {
name: prefix + '.' + param.key.name || param.key.value
});
}
case 'RestProperty': // (a, ...b)
Expand Down
3 changes: 2 additions & 1 deletion src/infer/properties.js
Expand Up @@ -12,6 +12,7 @@ function prefixedName(name, prefix) {

function propertyToDoc(property, prefix): CommentTag {
var type = flowDoctrine(property.value);
var name = property.key.name || property.key.value
if (property.optional) {
type = {
type: 'OptionalType',
Expand All @@ -20,7 +21,7 @@ function propertyToDoc(property, prefix): CommentTag {
}
return {
title: 'property',
name: prefixedName(property.key.name, prefix),
name: prefixedName(name, prefix),
lineNumber: property.loc.start.line,
type
};
Expand Down

0 comments on commit 7fc6ca8

Please sign in to comment.