(
properties,
propsObj,
baseProps = [],
defaultProps = {},
flat = false,
parentType = null,
)
| 604 | }; |
| 605 | |
| 606 | const getProps = ( |
| 607 | properties, |
| 608 | propsObj, |
| 609 | baseProps = [], |
| 610 | defaultProps = {}, |
| 611 | flat = false, |
| 612 | parentType = null, |
| 613 | ) => { |
| 614 | const results = {}; |
| 615 | |
| 616 | properties.forEach(prop => { |
| 617 | const name = prop.getName(); |
| 618 | if (isReservedPropName(name)) { |
| 619 | return; |
| 620 | } |
| 621 | const propType = checker.getTypeOfSymbolAtLocation( |
| 622 | prop, |
| 623 | propsObj.valueDeclaration |
| 624 | ); |
| 625 | const baseProp = baseProps.find(p => p.getName() === name); |
| 626 | const defaultValue = defaultProps[name]; |
| 627 | |
| 628 | const required = |
| 629 | !isOptional(prop) && |
| 630 | (!baseProp || !isOptional(baseProp)) && |
| 631 | defaultValue === undefined; |
| 632 | |
| 633 | const description = getPropComment(prop); |
| 634 | |
| 635 | let result = { |
| 636 | description, |
| 637 | required, |
| 638 | defaultValue |
| 639 | }; |
| 640 | const type = getPropType(propType, propsObj, parentType); |
| 641 | // root object is inserted as type, |
| 642 | // otherwise it's flat in the value prop. |
| 643 | if (!flat) { |
| 644 | result.type = type; |
| 645 | } else { |
| 646 | result = {...result, ...type}; |
| 647 | } |
| 648 | |
| 649 | results[name] = result; |
| 650 | }); |
| 651 | |
| 652 | return results; |
| 653 | }; |
| 654 | |
| 655 | const getPropInfo = (propsObj, defaultProps) => { |
| 656 | const propsType = checker.getTypeOfSymbolAtLocation( |
no test coverage detected
searching dependent graphs…