diff --git a/src/client/rsg-components/Props/Props.spec.tsx b/src/client/rsg-components/Props/Props.spec.tsx
index 921fd5814..a0280aabe 100644
--- a/src/client/rsg-components/Props/Props.spec.tsx
+++ b/src/client/rsg-components/Props/Props.spec.tsx
@@ -605,13 +605,22 @@ describe('props columns', () => {
test('should render enum type', () => {
const { container } = renderFn(['foo: MyEnum'], [], [options.enum.declaration]);
-
- expect(getText(container)).toMatchInlineSnapshot(`
- "Prop name: foo
- Type: ${options.enum.expect.type}
- Default: Required
- Description:"
- `);
+ if (options.enum.expect.type === 'enum') {
+ expect(getText(container)).toMatchInlineSnapshot(`
+ "Prop name: foo
+ Type: ${options.enum.expect.type}
+ Default: Required
+ Description:
+ One of: One , Two"
+ `);
+ } else {
+ expect(getText(container)).toMatchInlineSnapshot(`
+ "Prop name: foo
+ Type: ${options.enum.expect.type}
+ Default: Required
+ Description:"
+ `);
+ }
});
test('should render tuple type with body in tooltip', () => {
diff --git a/src/client/rsg-components/Props/renderExtra.tsx b/src/client/rsg-components/Props/renderExtra.tsx
index a29c0f8ca..d1dda6e6d 100644
--- a/src/client/rsg-components/Props/renderExtra.tsx
+++ b/src/client/rsg-components/Props/renderExtra.tsx
@@ -4,16 +4,13 @@ import Type from 'rsg-components/Type';
import Code from 'rsg-components/Code';
import Name from 'rsg-components/Name';
import Markdown from 'rsg-components/Markdown';
+import { PropTypeDescriptor } from 'react-docgen';
-import { unquote, getType, showSpaces, PropDescriptor } from './util';
+import { unquote, getType, showSpaces, PropDescriptor, TypeDescriptor } from './util';
import renderDefault from './renderDefault';
import { renderType } from './renderType';
-function renderEnum(prop: PropDescriptor): React.ReactNode {
- const type = getType(prop);
- if (!type) {
- return undefined;
- }
+function renderEnum(type: PropTypeDescriptor | TypeDescriptor): React.ReactNode {
if (!Array.isArray(type.value)) {
return {type.value};
}
@@ -28,11 +25,7 @@ function renderEnum(prop: PropDescriptor): React.ReactNode {
);
}
-function renderUnion(prop: PropDescriptor): React.ReactNode {
- const type = getType(prop);
- if (!type) {
- return undefined;
- }
+function renderUnion(type: PropTypeDescriptor | TypeDescriptor): React.ReactNode {
if (!Array.isArray(type.value)) {
return {type.value};
}
@@ -68,24 +61,24 @@ function renderShape(props: Record) {
export default function renderExtra(prop: PropDescriptor): React.ReactNode {
const type = getType(prop);
- if (!prop.type || !type) {
+ if (!type) {
return null;
}
switch (type.name) {
case 'enum':
- return renderEnum(prop);
+ return renderEnum(type);
case 'union':
- return renderUnion(prop);
+ return renderUnion(type);
case 'shape':
- return renderShape(prop.type.value);
+ return prop.type && renderShape(prop.type.value);
case 'arrayOf':
if (type.value.name === 'shape') {
- return renderShape(prop.type.value.value);
+ return prop.type && renderShape(prop.type.value.value);
}
return null;
case 'objectOf':
if (type.value.name === 'shape') {
- return renderShape(prop.type.value.value);
+ return prop.type && renderShape(prop.type.value.value);
}
return null;
default: