@@ -259,13 +259,35 @@ impl<'a> TypeHumanizer<'a> {
259259 } ;
260260
261261 w. write_str ( & full_name) ?;
262+ if generic. is_empty ( ) {
263+ return Ok ( ( ) ) ;
264+ }
265+
262266 w. write_char ( '<' ) ?;
263- for ( i, param) in generic. iter ( ) . enumerate ( ) {
264- if i > 0 {
265- w. write_str ( ", " ) ?;
267+ let saved = self . level ;
268+ self . level = self . child_level ( ) ;
269+ let result = ( || {
270+ for ( i, param) in generic. iter ( ) . enumerate ( ) {
271+ if i > 0 {
272+ w. write_str ( ", " ) ?;
273+ }
274+ if param. is_const {
275+ w. write_str ( "const " ) ?;
276+ }
277+ w. write_str ( & param. name ) ?;
278+ if let Some ( constraint) = & param. constraint {
279+ w. write_str ( " extends " ) ?;
280+ self . write_type ( constraint, w) ?;
281+ }
282+ if let Some ( default_type) = & param. default {
283+ w. write_str ( " = " ) ?;
284+ self . write_type ( default_type, w) ?;
285+ }
266286 }
267- w. write_str ( & param. name ) ?;
268- }
287+ Ok ( ( ) )
288+ } ) ( ) ;
289+ self . level = saved;
290+ result?;
269291 w. write_char ( '>' )
270292 }
271293
@@ -515,29 +537,56 @@ impl<'a> TypeHumanizer<'a> {
515537 // ─── Call (alias call) ──────────────────────────────────────────
516538
517539 fn write_call_type < W : Write > ( & mut self , inner : & LuaAliasCallType , w : & mut W ) -> fmt:: Result {
518- let basic = match inner. get_call_kind ( ) {
519- LuaAliasCallKind :: Sub => "sub" ,
520- LuaAliasCallKind :: Add => "add" ,
521- LuaAliasCallKind :: KeyOf => "keyof" ,
522- LuaAliasCallKind :: Extends => "extends" ,
523- LuaAliasCallKind :: Select => "select" ,
524- LuaAliasCallKind :: Unpack => "unpack" ,
525- LuaAliasCallKind :: Index => "index" ,
526- LuaAliasCallKind :: RawGet => "rawget" ,
527- LuaAliasCallKind :: Merge => "Merge" ,
528- } ;
529- w. write_str ( basic) ?;
530- w. write_char ( '<' ) ?;
540+ let operands = inner. get_operands ( ) ;
531541 let saved = self . level ;
532542 self . level = self . child_level ( ) ;
533- for ( i, ty) in inner. get_operands ( ) . iter ( ) . enumerate ( ) {
534- if i > 0 {
535- w. write_char ( ',' ) ?;
543+ let result = ( || match inner. get_call_kind ( ) {
544+ LuaAliasCallKind :: KeyOf => {
545+ w. write_str ( "keyof " ) ?;
546+ for ( i, ty) in operands. iter ( ) . enumerate ( ) {
547+ if i > 0 {
548+ w. write_char ( ',' ) ?;
549+ }
550+ self . write_type ( ty, w) ?;
551+ }
552+ Ok ( ( ) )
536553 }
537- self . write_type ( ty, w) ?;
538- }
554+ LuaAliasCallKind :: Extends if operands. len ( ) == 2 => {
555+ self . write_type ( & operands[ 0 ] , w) ?;
556+ w. write_str ( " extends " ) ?;
557+ self . write_type ( & operands[ 1 ] , w)
558+ }
559+ LuaAliasCallKind :: Index if operands. len ( ) == 2 => {
560+ self . write_type ( & operands[ 0 ] , w) ?;
561+ w. write_char ( '[' ) ?;
562+ self . write_type ( & operands[ 1 ] , w) ?;
563+ w. write_char ( ']' )
564+ }
565+ call_kind => {
566+ let basic = match call_kind {
567+ LuaAliasCallKind :: Sub => "sub" ,
568+ LuaAliasCallKind :: Add => "add" ,
569+ LuaAliasCallKind :: KeyOf => "keyof" ,
570+ LuaAliasCallKind :: Extends => "extends" ,
571+ LuaAliasCallKind :: Select => "select" ,
572+ LuaAliasCallKind :: Unpack => "unpack" ,
573+ LuaAliasCallKind :: Index => "index" ,
574+ LuaAliasCallKind :: RawGet => "rawget" ,
575+ LuaAliasCallKind :: Merge => "Merge" ,
576+ } ;
577+ w. write_str ( basic) ?;
578+ w. write_char ( '<' ) ?;
579+ for ( i, ty) in operands. iter ( ) . enumerate ( ) {
580+ if i > 0 {
581+ w. write_char ( ',' ) ?;
582+ }
583+ self . write_type ( ty, w) ?;
584+ }
585+ w. write_char ( '>' )
586+ }
587+ } ) ( ) ;
539588 self . level = saved;
540- w . write_char ( '>' )
589+ result
541590 }
542591
543592 // ─── DocFunction ────────────────────────────────────────────────
0 commit comments