in src/utils/getFlowTypeFromReactComponent.ts [63:123]
export function applyToFlowTypeProperties(
documentation: Documentation,
path: NodePath,
callback: (propertyPath: NodePath, params: TypeParameters | null) => void,
typeParams: TypeParameters | null,
importer: Importer,
): void {
if (path.node.properties) {
path
.get('properties')
.each(propertyPath => callback(propertyPath, typeParams));
} else if (path.node.members) {
path
.get('members')
.each(propertyPath => callback(propertyPath, typeParams));
} else if (path.node.type === 'InterfaceDeclaration') {
if (path.node.extends) {
applyExtends(documentation, path, callback, typeParams, importer);
}
path
.get('body', 'properties')
.each(propertyPath => callback(propertyPath, typeParams));
} else if (path.node.type === 'TSInterfaceDeclaration') {
if (path.node.extends) {
applyExtends(documentation, path, callback, typeParams, importer);
}
path
.get('body', 'body')
.each(propertyPath => callback(propertyPath, typeParams));
} else if (
path.node.type === 'IntersectionTypeAnnotation' ||
path.node.type === 'TSIntersectionType'
) {
path
.get('types')
.each(typesPath =>
applyToFlowTypeProperties(
documentation,
typesPath,
callback,
typeParams,
importer,
),
);
} else if (path.node.type !== 'UnionTypeAnnotation') {
// The react-docgen output format does not currently allow
// for the expression of union types
const typePath = resolveGenericTypeAnnotation(path, importer);
if (typePath) {
applyToFlowTypeProperties(
documentation,
typePath,
callback,
typeParams,
importer,
);
}
}
}