Is key-value pair available in Typescript?

The Solution to Is key-value pair available in Typescript? is


Is key-value pair available in Typescript?

Yes. Called an index signature:

interface Foo {
   [key: string]: Bar;
} 
let foo:Foo = {};

Here keys are string and values are Bar.

More

You can use an es6 Map for proper dictionaries, polyfilled by core-js.

~ Answered on 2016-04-07 05:40:30


Most Viewed Questions: