I have this object:
const events = {
i: 'insert',
u: 'update',
d: 'delete'
};
for some reason I am blanking on how to give the object an index signature - if I do this:
export interface EventsSignature {
[key:string]: string
}
const events = <EventsSignature>{
i: 'insert',
u: 'update',
d: 'delete'
};
that doesn't work, just overrides the object definition. Note I have the same problem when doing this:
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 do new OplogObservable().subs[type]
it will complain saying there is no index signature.