Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

react-docgen

Package Overview
Dependencies
Maintainers
3
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-docgen - npm Package Compare versions

Comparing version 3.0.0-beta11 to 3.0.0-beta12

59

dist/utils/getFlowTypeFromReactComponent.js

@@ -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": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc