@@ -293,7 +293,7 @@ function gatherComponents(sources, components = {}) {
293
293
const getPropType = ( propType , propObj , parentType = null ) => {
294
294
// Types can get namespace prefixes or not.
295
295
let name = checker . typeToString ( propType ) . replace ( / ^ R e a c t \. / , '' ) ;
296
- let value ;
296
+ let value , elements ;
297
297
const raw = name ;
298
298
299
299
const newParentType = ( parentType || [ ] ) . concat ( raw )
@@ -311,13 +311,13 @@ function gatherComponents(sources, components = {}) {
311
311
// Shapes & array support.
312
312
if ( ! PRIMITIVES . concat ( 'enum' , 'func' , 'union' ) . includes ( name ) ) {
313
313
if (
314
- name . includes ( '[]' ) ||
315
- name . includes ( 'Array' ) ||
316
- name === 'tuple'
314
+ // Excluding object with arrays in the raw.
315
+ ( name . includes ( '[]' ) && name . endsWith ( "]" ) ) ||
316
+ name . includes ( 'Array' )
317
317
) {
318
318
name = 'arrayOf' ;
319
319
const replaced = raw . replace ( '[]' , '' ) ;
320
- if ( unionSupport . includes ( ' replaced' ) ) {
320
+ if ( unionSupport . includes ( replaced ) ) {
321
321
// Simple types are easier.
322
322
value = {
323
323
name : getPropTypeName ( replaced ) ,
@@ -336,6 +336,14 @@ function gatherComponents(sources, components = {}) {
336
336
name = 'array' ;
337
337
}
338
338
}
339
+ } else if (
340
+ name === 'tuple' ||
341
+ ( name . startsWith ( '[' ) && name . endsWith ( ']' ) )
342
+ ) {
343
+ name = 'tuple' ;
344
+ elements = propType . resolvedTypeArguments . map (
345
+ t => getPropType ( t , propObj , newParentType )
346
+ ) ;
339
347
} else if (
340
348
BANNED_TYPES . includes ( name ) ||
341
349
( parentType && parentType . includes ( name ) )
@@ -369,6 +377,7 @@ function gatherComponents(sources, components = {}) {
369
377
return {
370
378
name,
371
379
value,
380
+ elements,
372
381
raw
373
382
} ;
374
383
} ;
0 commit comments