by romellem on 4/1/25, 5:05 PM with 5 comments
by TheCycoONE on 4/1/25, 11:21 PM
They transcribe to something better defined in javascript. Typescript itself akwardly sits on the fence of almost entirely erasable and some decisions only make sense if that was the goal, like import files having a js rather than the ts extension that would point to the file in source.
Enums become javascript objects in a very leaky abstraction full of footguns. There are plenty of articles that cover these and this author seems to have written them off as 'not holding it right' but a good language feature fits in the hand naturally to stretch the analogy.
by miningape on 4/1/25, 11:29 PM
Then abstraction starts leaking everywhere because it's trying to bridge between typescript and javascript and you start wishing you had either made an object (pure JS) or a literal union (pure TS).
by koshdim on 4/1/25, 7:49 PM
by tengbretson on 4/1/25, 8:56 PM
This counter example against using unions of literals would result in a compiler error ts(2367). Which only furthers the argument for using unions of literals instead.
by paulddraper on 4/1/25, 9:55 PM
And yet you can’t use symbols [1].
Author gives a valiant effort, but is defending the indefensible.