Skip to content

Commit 3a04eae

Browse files
Christine Abernathyfkling
authored andcommitted
Surface exported type name as alias and add method param optional flag (#83)
1 parent 7ec77b9 commit 3a04eae

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/utils/getMethodDocumentation.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@ import getFlowType from './getFlowType';
1414
import getParameterName from './getParameterName';
1515
import getPropertyName from './getPropertyName';
1616
import getTypeAnnotation from './getTypeAnnotation';
17+
import recast from 'recast';
18+
19+
const { types: { namedTypes: types } } = recast;
1720

1821
type MethodParameter = {
1922
name: string;
2023
type?: ?FlowTypeDescriptor;
24+
optional?: boolean;
2125
};
2226

2327
type MethodReturn = {
@@ -42,10 +46,14 @@ function getMethodParamsDoc(methodPath, jsDoc) {
4246
const typePath = getTypeAnnotation(paramPath);
4347
if (typePath) {
4448
type = getFlowType(typePath);
49+
if (types.GenericTypeAnnotation.check(typePath.node)) {
50+
type.alias = typePath.node.id.name;
51+
}
4552
}
4653

4754
const param = {
4855
name: getParameterName(paramPath),
56+
optional: paramPath.node.optional,
4957
type,
5058
};
5159

0 commit comments

Comments
 (0)