@@ -86,7 +86,11 @@ export function validateStateIsClean(page: string) {
8686// 1 | 2[] !== (1 | 2)[]
8787// () => 1 | 2 !== (() => 1) | 2
8888const 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 ;
9094} = {
9195 array ( context , type ) {
9296 return (
@@ -100,7 +104,7 @@ const typeRenderers: {
100104 indentationDepth ++ ;
101105 const parts : JSX . Element [ ] = [
102106 renderType ( context , type . checkType , TypeContext . conditionalCheck ) ,
103- < span class = "tsd-signature-symbol " > extends </ span > ,
107+ < span class = "tsd-signature-keyword " > extends </ span > ,
104108 renderType ( context , type . extendsType , TypeContext . conditionalExtends ) ,
105109 < br /> ,
106110 includeIndentation ( ) ,
@@ -142,11 +146,11 @@ const typeRenderers: {
142146 inferred ( context , type ) {
143147 return (
144148 < >
145- < span class = "tsd-signature-symbol " > infer </ span > { " " }
149+ < span class = "tsd-signature-keyword " > infer </ span > { " " }
146150 < span class = "tsd-kind-type-parameter" > { type . name } </ span >
147151 { type . constraint && (
148152 < >
149- < span class = "tsd-signature-symbol " > extends </ span >
153+ < span class = "tsd-signature-keyword " > extends </ span >
150154 { renderType ( context , type . constraint , TypeContext . inferredConstraint ) }
151155 </ >
152156 ) }
@@ -170,23 +174,28 @@ const typeRenderers: {
170174
171175 switch ( type . readonlyModifier ) {
172176 case "+" :
173- parts . push ( < span class = "tsd-signature-symbol " > readonly </ span > ) ;
177+ parts . push ( < span class = "tsd-signature-keyword " > readonly </ span > ) ;
174178 break ;
175179 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+ ) ;
177186 break ;
178187 }
179188
180189 parts . push (
181190 < span class = "tsd-signature-symbol" > [</ span > ,
182191 < 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 > ,
184193 renderType ( context , type . parameterType , TypeContext . mappedParameter ) ,
185194 ) ;
186195
187196 if ( type . nameType ) {
188197 parts . push (
189- < span class = "tsd-signature-symbol " > as </ span > ,
198+ < span class = "tsd-signature-keyword " > as </ span > ,
190199 renderType ( context , type . nameType , TypeContext . mappedName ) ,
191200 ) ;
192201 }
@@ -241,11 +250,11 @@ const typeRenderers: {
241250 predicate ( context , type ) {
242251 return (
243252 < >
244- { ! ! type . asserts && < span class = "tsd-signature-symbol " > asserts </ span > }
253+ { ! ! type . asserts && < span class = "tsd-signature-keyword " > asserts </ span > }
245254 < span class = "tsd-kind-parameter" > { type . name } </ span >
246255 { ! ! type . targetType && (
247256 < >
248- < span class = "tsd-signature-symbol " > is </ span >
257+ < span class = "tsd-signature-keyword " > is </ span >
249258 { renderType ( context , type . targetType , TypeContext . predicateTarget ) }
250259 </ >
251260 ) }
@@ -255,7 +264,7 @@ const typeRenderers: {
255264 query ( context , type ) {
256265 return (
257266 < >
258- < span class = "tsd-signature-symbol " > typeof </ span >
267+ < span class = "tsd-signature-keyword " > typeof </ span >
259268 { renderType ( context , type . queryType , TypeContext . queryTypeTarget ) }
260269 </ >
261270 ) ;
@@ -299,17 +308,26 @@ const typeRenderers: {
299308
300309 return name ;
301310 } ,
302- reflection ( context , type ) {
311+ reflection ( context , type , { topLevelLinks } ) {
303312 const members : JSX . Element [ ] = [ ] ;
304313 const children : DeclarationReflection [ ] = type . declaration . children || [ ] ;
305314
306315 indentationDepth ++ ;
307316
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+
308326 for ( const item of children ) {
309327 if ( item . getSignature && item . setSignature ) {
310328 members . push (
311329 < >
312- < span class = { getKindClass ( item ) } > { item . name } </ span >
330+ { renderName ( item ) }
313331 < span class = "tsd-signature-symbol" > : </ span >
314332 { renderType ( context , item . getSignature . type , TypeContext . none ) }
315333 </ > ,
@@ -320,8 +338,8 @@ const typeRenderers: {
320338 if ( item . getSignature ) {
321339 members . push (
322340 < >
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 ) }
325343 < span class = "tsd-signature-symbol" > (): </ span >
326344 { renderType ( context , item . getSignature . type , TypeContext . none ) }
327345 </ > ,
@@ -332,8 +350,8 @@ const typeRenderers: {
332350 if ( item . setSignature ) {
333351 members . push (
334352 < >
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 ) }
337355 < span class = "tsd-signature-symbol" > (</ span >
338356 { item . setSignature . parameters ?. map ( ( item ) => (
339357 < >
@@ -352,11 +370,11 @@ const typeRenderers: {
352370 for ( const sig of item . signatures ) {
353371 members . push (
354372 < >
355- < span class = { getKindClass ( sig ) } > { item . name } </ span >
373+ { renderName ( sig ) }
356374 { item . flags . isOptional && < span class = "tsd-signature-symbol" > ?</ span > }
357375 { context . memberSignatureTitle ( sig , {
358376 hideName : true ,
359- arrowStyle : true ,
377+ arrowStyle : false ,
360378 } ) }
361379 </ > ,
362380 ) ;
@@ -366,7 +384,7 @@ const typeRenderers: {
366384
367385 members . push (
368386 < >
369- < span class = { getKindClass ( item ) } > { item . name } </ span >
387+ { renderName ( item ) }
370388 < span class = "tsd-signature-symbol" > { item . flags . isOptional ? "?: " : ": " } </ span >
371389 { renderType ( context , item . type , TypeContext . none ) }
372390 </ > ,
@@ -468,7 +486,7 @@ const typeRenderers: {
468486 typeOperator ( context , type ) {
469487 return (
470488 < >
471- < span class = "tsd-signature-symbol " > { type . operator } </ span >
489+ < span class = "tsd-signature-keyword " > { type . operator } </ span >
472490 { renderType ( context , type . target , TypeContext . typeOperatorTarget ) }
473491 </ >
474492 ) ;
@@ -483,13 +501,18 @@ const typeRenderers: {
483501 } ,
484502} ;
485503
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+ ) {
487510 if ( ! type ) {
488511 return < span class = "tsd-signature-type" > any</ span > ;
489512 }
490513
491514 const renderFn = typeRenderers [ type . type ] ;
492- const rendered = renderFn ( context , type as never ) ;
515+ const rendered = renderFn ( context , type as never , options ) ;
493516
494517 if ( type . needsParenthesis ( where ) ) {
495518 return (
@@ -504,6 +527,10 @@ function renderType(context: DefaultThemeRenderContext, type: Type | undefined,
504527 return rendered ;
505528}
506529
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 ) ;
509536}
0 commit comments