(json)
| 512 | } |
| 513 | |
| 514 | function rebuildInterfaces(json) { |
| 515 | let exports = {}; |
| 516 | if (!json.exports) { |
| 517 | return exports; |
| 518 | } |
| 519 | Object.keys(json.exports).forEach(key => { |
| 520 | currentlyProcessing = key; |
| 521 | if (key === 'links') { |
| 522 | console.log('skipping links'); |
| 523 | return; |
| 524 | } |
| 525 | let item = json.exports[key]; |
| 526 | if (item?.type == null) { |
| 527 | // todo what to do here?? |
| 528 | exports[item.name] = 'UNTYPED'; |
| 529 | return; |
| 530 | } |
| 531 | if (item.props?.type === 'identifier') { |
| 532 | // todo what to do here?? |
| 533 | exports[item.name] = 'UNTYPED'; |
| 534 | return; |
| 535 | } |
| 536 | if (item.type === 'component') { |
| 537 | let compInterface = {}; |
| 538 | if (item.props && item.props.properties) { |
| 539 | Object.entries(item.props.properties) |
| 540 | .sort(([keyA], [keyB]) => (keyA > keyB ? 1 : -1)) |
| 541 | .forEach(([, prop]) => { |
| 542 | if (prop.access === 'private') { |
| 543 | return; |
| 544 | } |
| 545 | let name = prop.name; |
| 546 | if (item.name === null) { |
| 547 | name = key; |
| 548 | } |
| 549 | let optional = prop.optional; |
| 550 | let defaultVal = prop.default; |
| 551 | let value = processType(prop.value); |
| 552 | compInterface[name] = {optional, defaultVal, value}; |
| 553 | }); |
| 554 | } else if (item.props && item.props.type === 'link') { |
| 555 | let prop = item.props; |
| 556 | let name = item.name; |
| 557 | if (item.name === null) { |
| 558 | name = key; |
| 559 | } |
| 560 | let optional = prop.optional; |
| 561 | let defaultVal = prop.default; |
| 562 | let value = processType(prop); |
| 563 | compInterface[name] = {optional, defaultVal, value}; |
| 564 | } |
| 565 | let name = item.name ?? key; |
| 566 | if (item.typeParameters?.length > 0) { |
| 567 | compInterface['typeParameters'] = |
| 568 | `<${item.typeParameters.map(processType).sort().join(', ')}>`; |
| 569 | } |
| 570 | if (item.props?.extends?.length > 0) { |
| 571 | compInterface['extend'] = |
no test coverage detected