basarat/typescript-collections

Dictionary not working

Closed this issue · 1 comments

Hi, looks like you dictionary isn't working:

var dict = new collections.Dictionary<{x:number},string>();   
console.log(dict.getValue({x:2}));   
dict.setValue({x:1}, 'x=1');   
console.log(dict.getValue({x:2}));   

I created a dictionary with a key: {x:number}

  1. Looking for the value for {x:2} returns undefined, which is correct.
  2. Then I setValue for key {x:1} to 'x=1'.
  3. Now, when I look for the value associated with key {x:2} I get 'x=1' - Incorrect, there should still be no value with key of {x:2}

key: {x:number} You need to provide a toString implementation: https://github.com/basarat/typescript-collections#a-note-on-equality