(symbol, source)
| 417 | }; |
| 418 | |
| 419 | const getDefaultProps = (symbol, source) => { |
| 420 | const statements = source.statements.filter( |
| 421 | stmt => |
| 422 | (!!stmt.name && |
| 423 | checker.getSymbolAtLocation(stmt.name) === symbol) || |
| 424 | ts.isExpressionStatement(stmt) || |
| 425 | ts.isVariableStatement(stmt) |
| 426 | ); |
| 427 | return statements.reduce((acc, statement) => { |
| 428 | let propMap = {}; |
| 429 | |
| 430 | statement.getChildren().forEach(child => { |
| 431 | let {right} = child; |
| 432 | if (right && ts.isIdentifier(right)) { |
| 433 | const value = source.locals.get(right.escapedText); |
| 434 | if ( |
| 435 | value && |
| 436 | value.valueDeclaration && |
| 437 | ts.isVariableDeclaration(value.valueDeclaration) && |
| 438 | value.valueDeclaration.initializer |
| 439 | ) { |
| 440 | right = value.valueDeclaration.initializer; |
| 441 | } |
| 442 | } |
| 443 | if (right) { |
| 444 | const {properties} = right; |
| 445 | if (properties) { |
| 446 | propMap = getDefaultPropsValues(properties); |
| 447 | } |
| 448 | } |
| 449 | }); |
| 450 | |
| 451 | return { |
| 452 | ...acc, |
| 453 | ...propMap |
| 454 | }; |
| 455 | }, {}); |
| 456 | }; |
| 457 | |
| 458 | const getPropComment = symbol => { |
| 459 | // Doesn't work too good with the JsDocTags losing indentation. |
no test coverage detected
searching dependent graphs…