function getDefaultValue()

in src/handlers/defaultPropsHandler.ts [13:43]


function getDefaultValue(path: NodePath, importer: Importer) {
  let node = path.node;
  let defaultValue;
  if (t.Literal.check(node)) {
    // @ts-ignore
    defaultValue = node.raw;
  } else {
    if (t.AssignmentPattern.check(path.node)) {
      path = resolveToValue(path.get('right'), importer);
    } else {
      path = resolveToValue(path, importer);
    }
    if (t.ImportDeclaration.check(path.node)) {
      defaultValue = node.name;
    } else {
      node = path.node;
      defaultValue = printValue(path);
    }
  }
  if (typeof defaultValue !== 'undefined') {
    return {
      value: defaultValue,
      computed:
        t.CallExpression.check(node) ||
        t.MemberExpression.check(node) ||
        t.Identifier.check(node),
    };
  }

  return null;
}