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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -