UNPKG

react-docgen

Version:

A CLI and toolkit to extract information from React components for documentation generation.

28 lines (23 loc) 885 B
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = isRequiredPropType; var _getMembers = _interopRequireDefault(require("../utils/getMembers")); /* * Copyright (c) 2015, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * * */ /** * Returns true of the prop is required, according to its type defintion */ function isRequiredPropType(path) { return (0, _getMembers.default)(path).some(member => !member.computed && member.path.node.name === 'isRequired' || member.computed && member.path.node.value === 'isRequired'); }