UNPKG

435 BJavaScriptView Raw
1const t = require('@babel/types');
2const flowDoctrine = require('./flow_doctrine');
3const tsDoctrine = require('./ts_doctrine');
4
5function typeAnnotation(type) {
6 if (t.isFlow(type)) {
7 if (t.isTypeAnnotation(type)) {
8 type = type.typeAnnotation;
9 }
10
11 return flowDoctrine(type);
12 }
13
14 if (t.isTSTypeAnnotation(type)) {
15 type = type.typeAnnotation;
16 }
17
18 return tsDoctrine(type);
19}
20
21module.exports = typeAnnotation;