Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescriprt specify type of key

var stuff: { [key: string]: string; } = {};
stuff['a'] = ''; // ok
stuff['a'] = 4;  // error

// ... or, if you're using this a lot and don't want to type so much ...
interface StringMap { [key: string]: string; }
var stuff2: StringMap = { };
// same as above
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #typescriprt #type #key
ADD COMMENT
Topic
Name
7+8 =