News for hackers. Stuff that matters.
Re:Problems with TypeScript by hopia on Wednesday January 15, 2020 @11:34PM (#22061712)
Yes, you're right, it should be an integer comparison check ultimately.

> TypeScript essentially does that, except that the tags are not going to be optimized by the compiler

What do you mean by this? Typescript erases type information during compilation. So you would not be able to emulate pattern matching against types on TS. Or you could if you manually added some common tag to every single data type like interface.

Or are you talking about just compile-time type checking on TS?

Re:Problems with TypeScript by mixedCase on Thursday January 16, 2020 @08:51AM (#22064462)
> Or you could if you manually added some common tag to every single data type like interface.

This is how you emulate them, I took it for granted and neglected to explicitly mention this is a moderately popular convention in TypeScript (those are the tags I referred to). fp-ts for example uses it all over the place.

With this the end result is essentially the same with compile-time type-safety for everything, and compiled down to an untyped binary or an untyped JS blob.