Typescript array of key value pairs declaration -


confused following declaration:

constructor(controls: {[key: string]: abstractcontrol}, optionals?: {[key: string]: boolean}, validator?: validatorfn, asyncvalidator?: asyncvalidatorfn) 

what type of controls (first parameter)? object array of key value pairs key string , value abstractcontrol? thanks!

yes, guessed, it's js object key string , abstractcontrol values.
example:

{     "control1": new control(),     "control2": new control() } 

edit

you can declare variable of type in 2 ways:

let controls: { [key: string]: abstractcontrol }; 

or

interface controlsmap {     [key: string]: abstractcontrol; }  let controls: controlsmap; 

or better:

interface controlsmap<t extends abstractcontrol> {     [key: string]: t; }  let controls1: controlsmap<abstractcontrol>; let controls2: controlsmap<mycontrol>; 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -