(path, node)
| 113 | }); |
| 114 | |
| 115 | function processPath(path, node) { |
| 116 | if (path.isTSParenthesizedType()) { |
| 117 | return processExport(path.get('typeAnnotation'), node); |
| 118 | } |
| 119 | if (path.isTSAsExpression()) { |
| 120 | // not sure why I can't pass typeAnnotation instead |
| 121 | return processExport(path.get('expression'), node); |
| 122 | } |
| 123 | if (path.isVariableDeclarator()) { |
| 124 | if (!path.node.init) { |
| 125 | node.id = `${asset.filePath}:${path.node.id.name}`; |
| 126 | node.name = path.node.id.name; |
| 127 | return Object.assign(node, {type: 'any'}); |
| 128 | } |
| 129 | |
| 130 | let docs = getJSDocs(path.parentPath); |
| 131 | processExport(path.get('init'), node); |
| 132 | addDocs(node, docs); |
| 133 | if (node.type === 'interface' || node.type === 'component') { |
| 134 | node.id = `${asset.filePath}:${path.node.id.name}`; |
| 135 | node.name = path.node.id.name; |
| 136 | } |
| 137 | return node; |
| 138 | } |
| 139 | |
| 140 | if (isReactForwardRef(path)) { |
| 141 | return processExport(path.get('arguments.0'), node); |
| 142 | } |
| 143 | |
| 144 | if (isCollectionComponent(path)) { |
| 145 | return processExport(path.get('arguments.1'), node); |
| 146 | } |
| 147 | |
| 148 | if (path.isClassDeclaration()) { |
| 149 | let properties = {}; |
| 150 | for (let propertyPath of path.get('body.body')) { |
| 151 | let property = processExport(propertyPath); |
| 152 | if (property) { |
| 153 | properties[property.name] = property; |
| 154 | } else { |
| 155 | console.log('UNKNOWN PROPERTY', propertyPath.node); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | let exts = path.node.superClass ? [processExport(path.get('superClass'))] : []; |
| 160 | let docs = getJSDocs(path); |
| 161 | |
| 162 | return Object.assign( |
| 163 | node, |
| 164 | addDocs( |
| 165 | { |
| 166 | type: 'interface', |
| 167 | id: `${asset.filePath}:${path.node.id.name}`, |
| 168 | name: path.node.id.name, |
| 169 | extends: exts, |
| 170 | properties, |
| 171 | typeParameters: path.node.typeParameters |
| 172 | ? path.get('typeParameters.params').map(p => processExport(p)) |
no test coverage detected