Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/utils/__tests__/getPropType-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,44 @@ describe('getPropType', () => {
});
});

it('detects descriptions on nested types in arrayOf', () => {
expect(
getPropType(
expression(`arrayOf(
/**
* test2
*/
string
)`),
),
).toEqual({
name: 'arrayOf',
description: 'test2',
value: {
name: 'string',
},
});
});

it('detects descriptions on nested types in objectOf', () => {
expect(
getPropType(
expression(`objectOf(
/**
* test2
*/
string
)`),
),
).toEqual({
name: 'objectOf',
description: 'test2',
value: {
name: 'string',
},
});
});

it('detects descriptions on nested types in shapes', () => {
expect(
getPropType(
Expand Down
12 changes: 12 additions & 0 deletions src/utils/getPropType.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ function getPropTypeOneOfType(argumentPath) {

function getPropTypeArrayOf(argumentPath) {
const type: PropTypeDescriptor = { name: 'arrayOf' };

const docs = getDocblock(argumentPath);
if (docs) {
type.description = docs;
}

const subType = getPropType(argumentPath);

if (subType.name === 'unknown') {
Expand All @@ -99,6 +105,12 @@ function getPropTypeArrayOf(argumentPath) {

function getPropTypeObjectOf(argumentPath) {
const type: PropTypeDescriptor = { name: 'objectOf' };

const docs = getDocblock(argumentPath);
if (docs) {
type.description = docs;
}

const subType = getPropType(argumentPath);

if (subType.name === 'unknown') {
Expand Down