Skip to content

Commit 7fc6ca8

Browse files
mrtnbrodertmcw
authored andcommitted
fix: special property names in flowtypes
1 parent a820174 commit 7fc6ca8

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/flow_doctrine.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function propertyToField(property) {
2727
}
2828
return {
2929
type: 'FieldType',
30-
key: property.key.name,
30+
key: property.key.name || property.key.value,
3131
value: type
3232
};
3333
}

src/infer/params.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ function paramToDoc(
197197
});
198198
}
199199
case 'ObjectProperty': {
200-
return _.assign(paramToDoc(param.value, prefix + '.' + param.key.name), {
201-
name: prefix + '.' + param.key.name
200+
return _.assign(paramToDoc(param.value, prefix + '.' + param.key.name || param.key.value), {
201+
name: prefix + '.' + param.key.name || param.key.value
202202
});
203203
}
204204
case 'RestProperty': // (a, ...b)

src/infer/properties.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function prefixedName(name, prefix) {
1212

1313
function propertyToDoc(property, prefix): CommentTag {
1414
var type = flowDoctrine(property.value);
15+
var name = property.key.name || property.key.value
1516
if (property.optional) {
1617
type = {
1718
type: 'OptionalType',
@@ -20,7 +21,7 @@ function propertyToDoc(property, prefix): CommentTag {
2021
}
2122
return {
2223
title: 'property',
23-
name: prefixedName(property.key.name, prefix),
24+
name: prefixedName(name, prefix),
2425
lineNumber: property.loc.start.line,
2526
type
2627
};

0 commit comments

Comments
 (0)