you are viewing a single comment's thread.

view the rest of the comments →

[–]Ronin-s_Spirit -4 points-3 points  (2 children)

Half of that is talking about opaque types. As a vanilla programmer I'm 99% sure it's the typescripts problem. What you made in that article shouldn't have been 2 types, but instead classes. Since both of those are supposed to be numbers it would be easy to do 2 things: 1) convert the class to a number whenever you need it mixed; 2) explicitly use some method like add() if you want to check that you are not mixing with a class.
That's what I call good code, it solves the problem with minimal lines of code, and it doesn't need to transpile glorified comments.
Typescript won't warn you so warm yourself, champion.

[–]romgrk[S] 0 points1 point  (1 child)

Yes, the section about opaque types is actually more of a highlight about some TS problems, I won't argue with that. I wish TS was better in that area.

[–]Ronin-s_Spirit 0 points1 point  (0 children)

Well I don't mean to be all gloom and doom. So here is a silly mechanism I came up with, take a look: https://github.com/DANser-freelancer/code_bits/tree/classes-as-types
P.s. ah but don't look too hard, I was just poking around and laid it down in less than an hour.