|
|
|
|
|
by mattstir
770 days ago
|
|
> The other implementation is detailed in this article, and requires the addition of unique field value to objects. That's not quite what ends up happening in this article though. The actual objects themselves are left unchanged (no new fields added), but you're telling the compiler that the value is actually an intersection type with that unique field. There a load-bearing `as Hash` in the return statement of `generateHash` in the article's example that makes it work without introducing runtime overhead. I definitely agree about native support for discriminated unions / nominal typing though, that would be fantastic. |
|