function getPropTypeHandler()

in src/handlers/propTypeHandler.ts [73:102]


function getPropTypeHandler(
  propName: string,
): (documentation: Documentation, path: NodePath, importer: Importer) => void {
  return function (
    documentation: Documentation,
    path: NodePath,
    importer: Importer,
  ) {
    let propTypesPath = getMemberValuePath(path, propName, importer);
    if (!propTypesPath) {
      return;
    }
    propTypesPath = resolveToValue(propTypesPath, importer);
    if (!propTypesPath) {
      return;
    }
    let getDescriptor;
    switch (propName) {
      case 'childContextTypes':
        getDescriptor = documentation.getChildContextDescriptor;
        break;
      case 'contextTypes':
        getDescriptor = documentation.getContextDescriptor;
        break;
      default:
        getDescriptor = documentation.getPropDescriptor;
    }
    amendPropTypes(getDescriptor.bind(documentation), propTypesPath, importer);
  };
}