@@ -86,7 +86,11 @@ export function validateStateIsClean(page: string) {
86
86
// 1 | 2[] !== (1 | 2)[]
87
87
// () => 1 | 2 !== (() => 1) | 2
88
88
const typeRenderers : {
89
- [ K in keyof TypeKindMap ] : ( context : DefaultThemeRenderContext , type : TypeKindMap [ K ] ) => JSX . Element ;
89
+ [ K in keyof TypeKindMap ] : (
90
+ context : DefaultThemeRenderContext ,
91
+ type : TypeKindMap [ K ] ,
92
+ options : { topLevelLinks : boolean } ,
93
+ ) => JSX . Element ;
90
94
} = {
91
95
array ( context , type ) {
92
96
return (
@@ -100,7 +104,7 @@ const typeRenderers: {
100
104
indentationDepth ++ ;
101
105
const parts : JSX . Element [ ] = [
102
106
renderType ( context , type . checkType , TypeContext . conditionalCheck ) ,
103
- < span class = "tsd-signature-symbol " > extends </ span > ,
107
+ < span class = "tsd-signature-keyword " > extends </ span > ,
104
108
renderType ( context , type . extendsType , TypeContext . conditionalExtends ) ,
105
109
< br /> ,
106
110
includeIndentation ( ) ,
@@ -142,11 +146,11 @@ const typeRenderers: {
142
146
inferred ( context , type ) {
143
147
return (
144
148
< >
145
- < span class = "tsd-signature-symbol " > infer </ span > { " " }
149
+ < span class = "tsd-signature-keyword " > infer </ span > { " " }
146
150
< span class = "tsd-kind-type-parameter" > { type . name } </ span >
147
151
{ type . constraint && (
148
152
< >
149
- < span class = "tsd-signature-symbol " > extends </ span >
153
+ < span class = "tsd-signature-keyword " > extends </ span >
150
154
{ renderType ( context , type . constraint , TypeContext . inferredConstraint ) }
151
155
</ >
152
156
) }
@@ -170,23 +174,28 @@ const typeRenderers: {
170
174
171
175
switch ( type . readonlyModifier ) {
172
176
case "+" :
173
- parts . push ( < span class = "tsd-signature-symbol " > readonly </ span > ) ;
177
+ parts . push ( < span class = "tsd-signature-keyword " > readonly </ span > ) ;
174
178
break ;
175
179
case "-" :
176
- parts . push ( < span class = "tsd-signature-symbol" > -readonly </ span > ) ;
180
+ parts . push (
181
+ < >
182
+ < span class = "tsd-signature-symbol" > -</ span >
183
+ < span class = "tsd-signature-keyword" > readonly </ span >
184
+ </ > ,
185
+ ) ;
177
186
break ;
178
187
}
179
188
180
189
parts . push (
181
190
< span class = "tsd-signature-symbol" > [</ span > ,
182
191
< span class = "tsd-kind-type-parameter" > { type . parameter } </ span > ,
183
- < span class = "tsd-signature-symbol " > in </ span > ,
192
+ < span class = "tsd-signature-keyword " > in </ span > ,
184
193
renderType ( context , type . parameterType , TypeContext . mappedParameter ) ,
185
194
) ;
186
195
187
196
if ( type . nameType ) {
188
197
parts . push (
189
- < span class = "tsd-signature-symbol " > as </ span > ,
198
+ < span class = "tsd-signature-keyword " > as </ span > ,
190
199
renderType ( context , type . nameType , TypeContext . mappedName ) ,
191
200
) ;
192
201
}
@@ -241,11 +250,11 @@ const typeRenderers: {
241
250
predicate ( context , type ) {
242
251
return (
243
252
< >
244
- { ! ! type . asserts && < span class = "tsd-signature-symbol " > asserts </ span > }
253
+ { ! ! type . asserts && < span class = "tsd-signature-keyword " > asserts </ span > }
245
254
< span class = "tsd-kind-parameter" > { type . name } </ span >
246
255
{ ! ! type . targetType && (
247
256
< >
248
- < span class = "tsd-signature-symbol " > is </ span >
257
+ < span class = "tsd-signature-keyword " > is </ span >
249
258
{ renderType ( context , type . targetType , TypeContext . predicateTarget ) }
250
259
</ >
251
260
) }
@@ -255,7 +264,7 @@ const typeRenderers: {
255
264
query ( context , type ) {
256
265
return (
257
266
< >
258
- < span class = "tsd-signature-symbol " > typeof </ span >
267
+ < span class = "tsd-signature-keyword " > typeof </ span >
259
268
{ renderType ( context , type . queryType , TypeContext . queryTypeTarget ) }
260
269
</ >
261
270
) ;
@@ -299,17 +308,26 @@ const typeRenderers: {
299
308
300
309
return name ;
301
310
} ,
302
- reflection ( context , type ) {
311
+ reflection ( context , type , { topLevelLinks } ) {
303
312
const members : JSX . Element [ ] = [ ] ;
304
313
const children : DeclarationReflection [ ] = type . declaration . children || [ ] ;
305
314
306
315
indentationDepth ++ ;
307
316
317
+ const renderName = ( named : Reflection ) =>
318
+ topLevelLinks ? (
319
+ < a class = { getKindClass ( named ) } href = { context . urlTo ( named ) } >
320
+ { named . name }
321
+ </ a >
322
+ ) : (
323
+ < span class = { getKindClass ( named ) } > { named . name } </ span >
324
+ ) ;
325
+
308
326
for ( const item of children ) {
309
327
if ( item . getSignature && item . setSignature ) {
310
328
members . push (
311
329
< >
312
- < span class = { getKindClass ( item ) } > { item . name } </ span >
330
+ { renderName ( item ) }
313
331
< span class = "tsd-signature-symbol" > : </ span >
314
332
{ renderType ( context , item . getSignature . type , TypeContext . none ) }
315
333
</ > ,
@@ -320,8 +338,8 @@ const typeRenderers: {
320
338
if ( item . getSignature ) {
321
339
members . push (
322
340
< >
323
- < span class = "tsd-signature-symbol " > get </ span >
324
- < span class = { getKindClass ( item . getSignature ) } > { item . name } </ span >
341
+ < span class = "tsd-signature-keyword " > get </ span >
342
+ { renderName ( item . getSignature ) }
325
343
< span class = "tsd-signature-symbol" > (): </ span >
326
344
{ renderType ( context , item . getSignature . type , TypeContext . none ) }
327
345
</ > ,
@@ -332,8 +350,8 @@ const typeRenderers: {
332
350
if ( item . setSignature ) {
333
351
members . push (
334
352
< >
335
- < span class = "tsd-signature-symbol " > set </ span >
336
- < span class = { getKindClass ( item . setSignature ) } > { item . name } </ span >
353
+ < span class = "tsd-signature-keyword " > set </ span >
354
+ { renderName ( item . setSignature ) }
337
355
< span class = "tsd-signature-symbol" > (</ span >
338
356
{ item . setSignature . parameters ?. map ( ( item ) => (
339
357
< >
@@ -352,11 +370,11 @@ const typeRenderers: {
352
370
for ( const sig of item . signatures ) {
353
371
members . push (
354
372
< >
355
- < span class = { getKindClass ( sig ) } > { item . name } </ span >
373
+ { renderName ( sig ) }
356
374
{ item . flags . isOptional && < span class = "tsd-signature-symbol" > ?</ span > }
357
375
{ context . memberSignatureTitle ( sig , {
358
376
hideName : true ,
359
- arrowStyle : true ,
377
+ arrowStyle : false ,
360
378
} ) }
361
379
</ > ,
362
380
) ;
@@ -366,7 +384,7 @@ const typeRenderers: {
366
384
367
385
members . push (
368
386
< >
369
- < span class = { getKindClass ( item ) } > { item . name } </ span >
387
+ { renderName ( item ) }
370
388
< span class = "tsd-signature-symbol" > { item . flags . isOptional ? "?: " : ": " } </ span >
371
389
{ renderType ( context , item . type , TypeContext . none ) }
372
390
</ > ,
@@ -468,7 +486,7 @@ const typeRenderers: {
468
486
typeOperator ( context , type ) {
469
487
return (
470
488
< >
471
- < span class = "tsd-signature-symbol " > { type . operator } </ span >
489
+ < span class = "tsd-signature-keyword " > { type . operator } </ span >
472
490
{ renderType ( context , type . target , TypeContext . typeOperatorTarget ) }
473
491
</ >
474
492
) ;
@@ -483,13 +501,18 @@ const typeRenderers: {
483
501
} ,
484
502
} ;
485
503
486
- function renderType ( context : DefaultThemeRenderContext , type : Type | undefined , where : TypeContext ) {
504
+ function renderType (
505
+ context : DefaultThemeRenderContext ,
506
+ type : Type | undefined ,
507
+ where : TypeContext ,
508
+ options : { topLevelLinks : boolean } = { topLevelLinks : false } ,
509
+ ) {
487
510
if ( ! type ) {
488
511
return < span class = "tsd-signature-type" > any</ span > ;
489
512
}
490
513
491
514
const renderFn = typeRenderers [ type . type ] ;
492
- const rendered = renderFn ( context , type as never ) ;
515
+ const rendered = renderFn ( context , type as never , options ) ;
493
516
494
517
if ( type . needsParenthesis ( where ) ) {
495
518
return (
@@ -504,6 +527,10 @@ function renderType(context: DefaultThemeRenderContext, type: Type | undefined,
504
527
return rendered ;
505
528
}
506
529
507
- export function type ( context : DefaultThemeRenderContext , type : Type | undefined ) {
508
- return renderType ( context , type , TypeContext . none ) ;
530
+ export function type (
531
+ context : DefaultThemeRenderContext ,
532
+ type : Type | undefined ,
533
+ options : { topLevelLinks : boolean } = { topLevelLinks : false } ,
534
+ ) {
535
+ return renderType ( context , type , TypeContext . none , options ) ;
509
536
}
0 commit comments