4 ms·
In TypeScript, this can be achieved using an assertion to the never type. I don't think it exists in C#, though.
by nikeee 8y ago
In TypeScript, this can be achieved using an assertion to the never type. I don't think it exists in C#, though.
- platz 8y agoThey aren't real guarantees in TypeScript, because the type system doesn't guarantee anything about the actual values that are flowing through the system. i.e. you have to code everything in TypeScript and make sure everyone follows the best practices.
- Dylan16807 8y agoMost statically-typed languages don't verify types at runtime either. As long as you enforce types at the boundaries between typed and untyped code, you should be fine. And enforcing invariants at the boundaries of your code is pretty important for all languages.
- platz 8y agothe point is that in FP languages, pattern matching uses closed ADTs, so you always know at compile time if you've covered all the cases.
- Dylan16807 8y agoHuh, you have do something with returning from a switch in typescript if you want it to make sure all cases are covered. So it's close but not quite there.