@@ -283,65 +283,72 @@ const typeRenderers: {
283
283
return name ;
284
284
} ,
285
285
reflection ( context , type , { needsParens } ) {
286
- if ( type . declaration . children ) {
287
- // Object literal
288
- return (
289
- < >
290
- < span class = "tsd-signature-symbol" > { "{ " } </ span >
291
- { join ( < span class = "tsd-signature-symbol" > ; </ span > , type . declaration . children , ( item ) => {
292
- if ( item . getSignature && item . setSignature ) {
293
- return (
294
- < >
295
- { item . name }
296
- < span class = "tsd-signature-symbol" > : </ span >
297
- { renderType ( context , item . getSignature . type ) }
298
- </ >
299
- ) ;
300
- }
286
+ const members : JSX . Element [ ] = [ ] ;
301
287
302
- if ( item . getSignature ) {
303
- return (
304
- < >
305
- < span class = "tsd-signature-symbol" > get </ span >
306
- { item . name }
307
- < span class = "tsd-signature-symbol" > (): </ span >
308
- { renderType ( context , item . getSignature . type ) }
309
- </ >
310
- ) ;
311
- }
288
+ for ( const item of type . declaration . children || [ ] ) {
289
+ if ( item . getSignature && item . setSignature ) {
290
+ members . push (
291
+ < >
292
+ { item . name }
293
+ < span class = "tsd-signature-symbol" > : </ span >
294
+ { renderType ( context , item . getSignature . type ) }
295
+ </ >
296
+ ) ;
297
+ continue ;
298
+ }
312
299
313
- if ( item . setSignature ) {
314
- return (
315
- < >
316
- < span class = "tsd-signature-symbol" > set </ span >
317
- { item . name }
318
- < span class = "tsd-signature-symbol" > (</ span >
319
- { item . setSignature . parameters ?. map ( ( item ) => (
320
- < >
321
- { item . name }
322
- < span class = "tsd-signature-symbol" > : </ span >
323
- { renderType ( context , item . type ) }
324
- </ >
325
- ) ) }
326
- < span class = "tsd-signature-symbol" > )</ span >
327
- </ >
328
- ) ;
329
- }
300
+ if ( item . getSignature ) {
301
+ members . push (
302
+ < >
303
+ < span class = "tsd-signature-symbol" > get </ span >
304
+ { item . name }
305
+ < span class = "tsd-signature-symbol" > (): </ span >
306
+ { renderType ( context , item . getSignature . type ) }
307
+ </ >
308
+ ) ;
309
+ continue ;
310
+ }
330
311
331
- return (
312
+ if ( item . setSignature ) {
313
+ members . push (
314
+ < >
315
+ < span class = "tsd-signature-symbol" > set </ span >
316
+ { item . name }
317
+ < span class = "tsd-signature-symbol" > (</ span >
318
+ { item . setSignature . parameters ?. map ( ( item ) => (
332
319
< >
333
320
{ item . name }
334
- < span class = "tsd-signature-symbol" > { item . flags . isOptional ? "?: " : ": " } </ span >
321
+ < span class = "tsd-signature-symbol" > : </ span >
335
322
{ renderType ( context , item . type ) }
336
323
</ >
337
- ) ;
338
- } ) }
339
- < span class = "tsd-signature-symbol" > { " }" } </ span >
324
+ ) ) }
325
+ < span class = "tsd-signature-symbol" > )</ span >
326
+ </ >
327
+ ) ;
328
+ continue ;
329
+ }
330
+
331
+ members . push (
332
+ < >
333
+ { item . name }
334
+ < span class = "tsd-signature-symbol" > { item . flags . isOptional ? "?: " : ": " } </ span >
335
+ { renderType ( context , item . type ) }
340
336
</ >
341
337
) ;
342
338
}
343
339
344
- if ( type . declaration . signatures ?. length === 1 ) {
340
+ if ( type . declaration . indexSignature ) {
341
+ const index = type . declaration . indexSignature ;
342
+ members . push (
343
+ < >
344
+ [{ index . parameters ! [ 0 ] . name } : { renderType ( context , index . parameters ! [ 0 ] . type ) } ]
345
+ < span class = "tsd-signature-symbol" > : </ span >
346
+ { renderType ( context , index . type ) }
347
+ </ >
348
+ ) ;
349
+ }
350
+
351
+ if ( ! members . length && type . declaration . signatures ?. length === 1 ) {
345
352
return (
346
353
< >
347
354
{ needsParens && < span class = "tsd-signature-symbol" > (</ span > }
@@ -354,16 +361,19 @@ const typeRenderers: {
354
361
) ;
355
362
}
356
363
357
- if ( type . declaration . signatures ) {
364
+ for ( const item of type . declaration . signatures || [ ] ) {
365
+ members . push ( context . memberSignatureTitle ( item , { hideName : true } ) ) ;
366
+ }
367
+
368
+ if ( members . length ) {
369
+ const membersWithSeparators = members . flatMap ( ( m ) => [ m , < span class = "tsd-signature-symbol" > ; </ span > ] ) ;
370
+ membersWithSeparators . pop ( ) ;
371
+
358
372
return (
359
373
< >
360
374
< span class = "tsd-signature-symbol" > { "{" } </ span >
361
- { join ( < span class = "tsd-signature-symbol" > ; </ span > , type . declaration . signatures , ( item ) =>
362
- context . memberSignatureTitle ( item , {
363
- hideName : true ,
364
- } )
365
- ) }
366
- < span class = "tsd-signature-symbol" > { " }" } </ span >
375
+ { membersWithSeparators }
376
+ < span class = "tsd-signature-symbol" > { "}" } </ span >
367
377
</ >
368
378
) ;
369
379
}
0 commit comments