zlacker

[parent] [thread] 5 comments
1. morshu+(OP)[view] [source] 2025-12-04 18:07:00
Valid JS is often not valid TS. Any nontrivial amount of JS copied into TS will generally not work without tweaks. When people say TS is a superset of JS, it's just some academic definition of syntax supersets that isn't practically true.

Non-exhaustive examples:

    let foo = 2
    foo = "foo"  // TS disallows type change
    let bar = {}
    bar.baz = 2  // TS disallows adding property
replies(2): >>anemat+Ud >>ddtayl+jg
2. anemat+Ud[view] [source] 2025-12-04 19:19:31
>>morshu+(OP)
Even syntactically, TS is not a superset of JS: https://anemato.de/blog/js-to-ts
replies(1): >>morshu+3o
3. ddtayl+jg[view] [source] 2025-12-04 19:30:39
>>morshu+(OP)
The amount of weird TS I see that attempts to keep the JS style of code while getting the compiler to stop being mad is strange. I will see hundreds of line of type inference work, when they could have just made an actual type.
replies(2): >>morshu+on >>Maxion+fL1
◧◩
4. morshu+on[view] [source] [discussion] 2025-12-04 20:01:23
>>ddtayl+jg
I feel like most people using TS are not doing it by personal choice but because someone else decided it
◧◩
5. morshu+3o[view] [source] [discussion] 2025-12-04 20:04:03
>>anemat+Ud
So it's a "sodium chloride" thing. Oh I hit this case too, and even this article looks familiar, probably cause I googled an error message
◧◩
6. Maxion+fL1[view] [source] [discussion] 2025-12-05 06:51:25
>>ddtayl+jg
I see this happening with people who are thrown in to coding TS, with little or no training / time to educate themselves.
[go to top]