|
|
|
|
|
by javcasas
2309 days ago
|
|
I work with Haskell, a language that some people call "pinnacle of type systems". Guess what would happen if I use `unsafeCoerce`? Exactly the same that would happen if I use `<any>` in Typescript. All the type guarantees go out of the window. In your code, if someone throws a bad class into the mix, it will blow up both in Typescript and in Java/C# and in any other programming language. But, somehow, blowing up in Typescript is way worse that blowing up in Java/C#. Go and tell me that when I'm not allowed to put `nulls` anywhere neither in Java nor in C#, because that's something I can do in Typescript today. |
|
Even if it's only a compile time check, and can therefore still be circumvented at runtime, this check for null values has still helped me out a lot. At least within a class it ensures my assumptions are consistent, which is not nothing.