TypeScript - Casting to Object When Initializing Required Property with an Array Literal -


i'm trying initialize object has interface type object literal:

return {             id: 0,             name: name,             localizedlabels: [                 {localecd: defaultlocalecd, label: name}             ],             localizeddescriptions: [],             usefornetworkbuild: false,             temporalsplitting: false,             compounds: [],             primaryelements: [],             defaultmapicon: null,             defaultregularicon: null,             markercolor: null,             nodeshape: null }; 

the type of object interface created called entity. it's got several parent interfaces. 1 causing problem "localizeddescriptions" property of localizableobject (sorry deep hierarchy):

export interface entity extends hubbase.persistableobject,                                  hublocalization.localizableobject,                                  hubbase.graphicallydisplayable {     name: string;     usefornetworkbuild: boolean;     temporalsplitting: boolean;     compounds: compound[];     primaryelements: element[]; } export interface localizedlabel extends hubbase.persistableobject {     localecd: string     label: string; }  export interface localizeddescription extends hubbase.persistableobject {     localecd: string     description: string; }  export interface localizableobject {     label?: string;     localizedlabels: localizedlabel[];     description?: string;     localizeddescriptions: localizeddescription; } 

the compiler giving error "localcd" property not being available, complaining [] initializer "localizeddescriptions":

i tried casting entire object literal entity. tried put cast before [] in assignment "localizeddescriptions". error persists. there way cast property remove error?

i'm using typescript 1.4.1.

export interface localizableobject {     label?: string;     localizedlabels: localizedlabel[];     description?: string;      // not array type, did mean localizeddescription[] ?     localizeddescriptions: localizeddescription; } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -