react-docgen
Advanced tools
Comparing version 3.0.0-beta11 to 3.0.0-beta12
@@ -6,2 +6,7 @@ 'use strict'; | ||
}); | ||
var _set = require('babel-runtime/core-js/set'); | ||
var _set2 = _interopRequireDefault(_set); | ||
exports.applyToFlowTypeProperties = applyToFlowTypeProperties; | ||
@@ -39,4 +44,16 @@ | ||
var types = _recast2.default.types.namedTypes; | ||
var types = _recast2.default.types.namedTypes; /* | ||
* 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. | ||
* | ||
* | ||
* | ||
*/ | ||
var supportedUtilityTypes = new _set2.default(['$Exact', '$ReadOnly']); | ||
/** | ||
@@ -47,13 +64,2 @@ * Given an React component (stateless or class) tries to find the | ||
*/ | ||
/* | ||
* 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. | ||
* | ||
* | ||
* | ||
*/ | ||
@@ -87,3 +93,5 @@ exports.default = function (path) { | ||
if (typePath && types.GenericTypeAnnotation.check(typePath.node)) { | ||
if (typePath && isSupportedUtilityType(typePath)) { | ||
typePath = unwrapUtilityType(typePath); | ||
} else if (typePath && types.GenericTypeAnnotation.check(typePath.node)) { | ||
typePath = (0, _resolveToValue2.default)(typePath.get('id')); | ||
@@ -122,3 +130,5 @@ if (!typePath || types.Identifier.check(typePath.node) || (0, _isUnreachableFlowType2.default)(typePath)) { | ||
var typePath = void 0; | ||
if (path && types.GenericTypeAnnotation.check(path.node)) { | ||
if (path && isSupportedUtilityType(path)) { | ||
typePath = unwrapUtilityType(path); | ||
} else if (path && types.GenericTypeAnnotation.check(path.node)) { | ||
typePath = (0, _resolveToValue2.default)(path.get('id')); | ||
@@ -133,2 +143,23 @@ if ((0, _isUnreachableFlowType2.default)(typePath)) { | ||
return typePath; | ||
} | ||
/** | ||
* See `supportedUtilityTypes` for which types are supported and | ||
* https://flow.org/en/docs/types/utilities/ for which types are available. | ||
*/ | ||
function isSupportedUtilityType(path) { | ||
if (types.GenericTypeAnnotation.check(path.node)) { | ||
var idPath = path.get('id'); | ||
return Boolean(idPath) && supportedUtilityTypes.has(idPath.node.name); | ||
} | ||
return false; | ||
} | ||
/** | ||
* Unwraps well known utility types. For example: | ||
* | ||
* $ReadOnly<T> => T | ||
*/ | ||
function unwrapUtilityType(path) { | ||
return path.get('typeParameters', 'params', 0); | ||
} |
{ | ||
"name": "react-docgen", | ||
"version": "3.0.0-beta11", | ||
"version": "3.0.0-beta12", | ||
"description": "A CLI and toolkit to extract information from React components for documentation generation.", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
194561
4522