I see in the code of the Typescript compiler, an implementation of "HashTable" (in the files src/compiler/core/hashTable.ts).
Do you know is there a way I can use it directly in my Typescript project ?
You can implement a very simple hashtable where the key is a string by defining an interface
class Person {
name: string;
}
interface HashTable<T> {
[key: string]: T;
}
var persons: HashTable<Person> = {};
persons["bob"] = new Person();
var bob = persons["bob"];
It can only be keyed on a string or a number though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With