Issue with HashMap Key and Data Class in TypeScript
I have a
I just found a bug because in some function, I was doing something like:
Thus, not having the Hash and Equal traits implemented on the output - although the return type is typed as
If I type my
Then I get typesafety but the
HashMap<Key, Value> with Key being:I just found a bug because in some function, I was doing something like:
Thus, not having the Hash and Equal traits implemented on the output - although the return type is typed as
Key - which breaks the HashMap.If I type my
Key as: Then I get typesafety but the
Data.struct function does not comply with the type. I feel like that is the whole purpose of Data to have those traits so it feels strange having this confusion in the resulting type, shouldn't the Data methods return T & Hash & Equal? What is the recommended way to deal with those types?