Currently, I have this object:
const events = {
i: 'insert',
u: 'update',
d: 'delete'
};
I am struggling to assign an index signature to the object. When I try the following:
export interface EventsSignature {
[key:string]: string
}
const events = <EventsSignature>{
i: 'insert',
u: 'update',
d: 'delete'
};
it doesn't seem to work as it simply overrides the initial object definition. The same issue arises when I attempt something similar with another code snippet:
export class OplogObservable {
private uri: string;
private coll: Collection;
collName: string;
isTailing = false;
private subs = {
all: new Subject<any>(),
update: new Subject<Object>(),
insert: new Subject<Object>(),
delete: new Subject<Object>(),
errors: new Subject<Object>(),
end: new Subject<Object>()
};
}
If I use new OplogObservable().subs[type]
, it throws an error mentioning the absence of an index signature.