typescript - How to declare iterable object of another interface type? -
so, here i'm trying make interface type of object contain specific interfaces in it. example:
export interface iuser { name: string; last: string; }; export interface iroom { users: object<iuser>; // wrong. }
i'm expecting, users like:
users: { 'user_id_goes_here': { name: 'john', last: 'doe' }, 'user_id_goes_here': { name: 'albert', last: 'einstein' }, ... }
is there way define interface member type this?
i think want this:
export interface room { users: usermap; } export interface usermap { [userid: string]: user; } export interface user { name: string; last: string; }
that [userid: string]: iuser;
what's called string index signature. means whenever use string index usermap
, iuser
.
Comments
Post a Comment