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
.
You can use an es6 Map
for proper dictionaries, polyfilled by core-js
.
~ Answered on 2016-04-07 05:40:30