Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const renderPropType = (
propType: any,
{ overrides = {}, shouldCollapseProps, components }: any
) => {
if (!components) {
components = allComponents;
} else {
components = { ...allComponents, ...components };
}
if (propType.kind === 'spread') {
const furtherProps = reduceToObj(propType.value);
if (Array.isArray(furtherProps) && furtherProps.length > 0) {
/* Only render the spread contents if they are a non-empty value, otherwise render the
* spread itself so we can see the spread of generics and other types that have not been
* converted into an object */
return furtherProps.map(p =>
renderPropType(p, { overrides, shouldCollapseProps, components })
);
}
}
let description;
if (propType.leadingComments) {
description = propType.leadingComments.reduce((acc, { value }) => acc.concat(`\n${value}`), '');
}
if (!propType.value) {
const renderPropType = (
propType: any,
{ overrides = {}, shouldCollapseProps, components }: any
) => {
if (!components) {
components = allComponents;
} else {
components = { ...allComponents, ...components };
}
if (propType.kind === "spread") {
const furtherProps = reduceToObj(propType.value);
if (Array.isArray(furtherProps) && furtherProps.length > 0) {
/* Only render the spread contents if they are a non-empty value, otherwise render the
* spread itself so we can see the spread of generics and other types that have not been
* converted into an object */
return furtherProps.map(p =>
renderPropType(p, { overrides, shouldCollapseProps, components })
);
}
}
let description;
if (propType.leadingComments) {
description = propType.leadingComments.reduce(
(acc, { value }) => acc.concat(`\n${value}`),
""
);
propTypes = resolvedTypes.types.reduce((acc, type) => [...acc, ...reduceToObj(type)], []);
}
(acc, type) => [...acc, ...reduceToObj(type)],
[],