Skip to content

Commit f14fff4

Browse files
Markus Hsi-Yang Fritzdanez
authored andcommitted
Add support for Flow literal string/number types
1 parent 34b647f commit f14fff4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/flow_doctrine.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ var oneToOne = {
1111
}
1212
};
1313

14+
var literalTypes = {
15+
'StringLiteralTypeAnnotation': 'StringLiteral',
16+
'NumberLiteralTypeAnnotation': 'NumberLiteral'
17+
};
18+
1419
function flowDoctrine(type) {
1520

1621
if (type.type in namedTypes) {
@@ -56,6 +61,13 @@ function flowDoctrine(type) {
5661
name: type.id.name
5762
};
5863
}
64+
65+
if (type.type in literalTypes) {
66+
return {
67+
type: literalTypes[type.type],
68+
name: type.value
69+
};
70+
}
5971
}
6072

6173
module.exports = flowDoctrine;

0 commit comments

Comments
 (0)