documentation/src/type_annotation.js
2019-04-25 08:13:33 -07:00

22 lines
435 B
JavaScript

const t = require('@babel/types');
const flowDoctrine = require('./flow_doctrine');
const tsDoctrine = require('./ts_doctrine');
function typeAnnotation(type) {
if (t.isFlow(type)) {
if (t.isTypeAnnotation(type)) {
type = type.typeAnnotation;
}
return flowDoctrine(type);
}
if (t.isTSTypeAnnotation(type)) {
type = type.typeAnnotation;
}
return tsDoctrine(type);
}
module.exports = typeAnnotation;