How does the hash variable syntax work in typescript?

TypeScript: Index Signatures

The syntax for defining the index is:

{ [Identifier: KeyType]: ValueType }

KeyType can be either string or number.

You could claim that the Identifier isn’t really needed since it doesn’t get used anywhere, but I think it’s required in order to force the class/interface designer to indicate what the hash map key should represent (an id, name, e-mail address, etc.). This also provides the possibility of having intellisense show the hash key name (as Visual Studio does for other languages), though I don’t think Typescript intellisense currently provides this.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)