@@ -66,28 +66,26 @@ export type TraceSeverity =
66
66
| 'CT_WARNING'
67
67
| 'CT_ERROR' ;
68
68
69
- export interface ChannelRef {
70
- kind : EntityTypes . channel ;
69
+ interface Ref {
70
+ kind : EntityTypes ;
71
71
id : number ;
72
72
name : string ;
73
73
}
74
74
75
- export interface SubchannelRef {
75
+ export interface ChannelRef extends Ref {
76
+ kind : EntityTypes . channel ;
77
+ }
78
+
79
+ export interface SubchannelRef extends Ref {
76
80
kind : EntityTypes . subchannel ;
77
- id : number ;
78
- name : string ;
79
81
}
80
82
81
- export interface ServerRef {
83
+ export interface ServerRef extends Ref {
82
84
kind : EntityTypes . server ;
83
- id : number ;
84
- name : string ;
85
85
}
86
86
87
- export interface SocketRef {
87
+ export interface SocketRef extends Ref {
88
88
kind : EntityTypes . socket ;
89
- id : number ;
90
- name : string ;
91
89
}
92
90
93
91
function channelRefToMessage ( ref : ChannelRef ) : ChannelRefMessage {
@@ -361,6 +359,8 @@ export const enum EntityTypes {
361
359
socket = 'socket' ,
362
360
}
363
361
362
+ type EntryOrderedMap = OrderedMap < number , { ref : Ref ; getInfo : ( ) => any } > ;
363
+
364
364
const entityMaps = {
365
365
[ EntityTypes . channel ] : new OrderedMap < number , ChannelEntry > ( ) ,
366
366
[ EntityTypes . subchannel ] : new OrderedMap < number , SubchannelEntry > ( ) ,
@@ -404,6 +404,8 @@ const generateRegisterFn = <R extends EntityTypes>(kind: R) => {
404
404
return nextId ++ ;
405
405
}
406
406
407
+ const entityMap : EntryOrderedMap = entityMaps [ kind ] ;
408
+
407
409
return (
408
410
name : string ,
409
411
getInfo : ( ) => InfoByType < R > ,
@@ -412,8 +414,7 @@ const generateRegisterFn = <R extends EntityTypes>(kind: R) => {
412
414
const id = getNextId ( ) ;
413
415
const ref = { id, name, kind } as RefByType < R > ;
414
416
if ( channelzEnabled ) {
415
- // @ts -expect-error typing issues
416
- entityMaps [ kind ] . setElement ( id , { ref, getInfo } ) ;
417
+ entityMap . setElement ( id , { ref, getInfo } ) ;
417
418
}
418
419
return ref ;
419
420
} ;
0 commit comments