MCPcopy
hub / github.com/plotly/dash / getDefaultPropsValues

Function getDefaultPropsValues

dash/extract-meta.js:521–568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

519 };
520
521 const getDefaultPropsValues = properties =>
522 properties.reduce((acc, p) => {
523 if (!p.name || !p.initializer) {
524 return acc;
525 }
526 let propName, value;
527
528 switch (p.name.kind) {
529 case ts.SyntaxKind.NumericLiteral:
530 case ts.SyntaxKind.StringLiteral:
531 case ts.SyntaxKind.Identifier:
532 propName = p.name.text;
533 break;
534 case ts.SyntaxKind.ComputedPropertyName:
535 propName = p.name.getText();
536 break;
537 }
538
539 const {initializer} = p;
540
541 switch (initializer.kind) {
542 case ts.SyntaxKind.StringLiteral:
543 value = `'${initializer.text}'`;
544 break;
545 case ts.SyntaxKind.NumericLiteral:
546 value = initializer.text;
547 break;
548 case ts.SyntaxKind.NullKeyword:
549 value = 'null';
550 break;
551 case ts.SyntaxKind.FalseKeyword:
552 value = 'false';
553 break;
554 case ts.SyntaxKind.TrueKeyword:
555 value = 'true';
556 break;
557 default:
558 try {
559 value = initializer.getText();
560 } catch (e) {
561 value = undefined;
562 }
563 }
564
565 acc[propName] = {value, computed: false};
566
567 return acc;
568 }, {});
569
570 const getDefaultPropsForClassComponent = (type, source) => {
571 // For class component, the type has its own property, then get the

Callers 3

getDefaultPropsFunction · 0.85
gatherComponentsFunction · 0.85

Calls 1

reduceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…