chore: address ts errors

This commit is contained in:
AVVS 2024-03-05 15:34:29 -08:00
parent cf321a80b1
commit 74ddb3bd6f
No known key found for this signature in database
GPG Key ID: 2B890ABACCC3E369
1 changed files with 15 additions and 14 deletions

View File

@ -66,28 +66,26 @@ export type TraceSeverity =
| 'CT_WARNING'
| 'CT_ERROR';
export interface ChannelRef {
interface Ref {
kind: EntityTypes;
id: number;
name: string;
}
export interface ChannelRef extends Ref {
kind: EntityTypes.channel;
id: number;
name: string;
}
export interface SubchannelRef {
export interface SubchannelRef extends Ref {
kind: EntityTypes.subchannel;
id: number;
name: string;
}
export interface ServerRef {
export interface ServerRef extends Ref {
kind: EntityTypes.server;
id: number;
name: string;
}
export interface SocketRef {
export interface SocketRef extends Ref {
kind: EntityTypes.socket;
id: number;
name: string;
}
function channelRefToMessage(ref: ChannelRef): ChannelRefMessage {
@ -361,6 +359,8 @@ export const enum EntityTypes {
socket = 'socket',
}
type EntryOrderedMap = OrderedMap<number, { ref: Ref; getInfo: () => any }>;
const entityMaps = {
[EntityTypes.channel]: new OrderedMap<number, ChannelEntry>(),
[EntityTypes.subchannel]: new OrderedMap<number, SubchannelEntry>(),
@ -404,6 +404,8 @@ const generateRegisterFn = <R extends EntityTypes>(kind: R) => {
return nextId++;
}
const entityMap: EntryOrderedMap = entityMaps[kind];
return (
name: string,
getInfo: () => InfoByType<R>,
@ -412,8 +414,7 @@ const generateRegisterFn = <R extends EntityTypes>(kind: R) => {
const id = getNextId();
const ref = { id, name, kind } as RefByType<R>;
if (channelzEnabled) {
// @ts-expect-error typing issues
entityMaps[kind].setElement(id, { ref, getInfo });
entityMap.setElement(id, { ref, getInfo });
}
return ref;
};