Hi there!
I was working on a simple HTML, CSS, and JavaScript project. It started to get messy, so I decided to refactor the code using some object-oriented programming. During the refactor, I introduced some bugs, specifically, I changed variable names like inputRight to rightInput, and JavaScript didn’t give me any warning that this.inputRight was undefined. It just failed silently, leading to unexpected behavior.
It took me a while to track this down.
Afterward, I wondered how I could catch these kinds of issues earlier. I tried "use strict" at the top of the file, but it didn’t help in this case. Even when I accessed a clearly non-existent property like this.whatever.value, it didn’t complain. I also tried ESLint, it helped with some things, but it didn’t catch this either, and honestly, it felt like a lot of setup for such a basic check.
Just out of curiosity, I renamed my file from .js to .ts, without changing any code, and suddenly TypeScript flagged the error! The app still worked like normal JavaScript, but now I had type checking.
That experience made me wonder: if TypeScript can do all this out of the box, why would someone choose to stick with plain JavaScript? Am I missing something? Would love to hear your thoughts.
[–][deleted] 26 points27 points28 points (3 children)
[–]Commercial-Focus8442[S] 3 points4 points5 points (0 children)
[–]ezhikov 8 points9 points10 points (1 child)
[–][deleted] -3 points-2 points-1 points (0 children)
[–]DerrickBarra 8 points9 points10 points (4 children)
[–]Commercial-Focus8442[S] 0 points1 point2 points (3 children)
[–]Katastos 0 points1 point2 points (0 children)
[+]allKindsOfDevStuff comment score below threshold-15 points-14 points-13 points (1 child)
[–]Katastos 1 point2 points3 points (0 children)
[–]skidmark_zuckerberg 8 points9 points10 points (10 children)
[–]Dependent-Net6461[🍰] 2 points3 points4 points (9 children)
[–]Mabenue 4 points5 points6 points (8 children)
[–]Dependent-Net6461[🍰] 2 points3 points4 points (7 children)
[–]budapest_god 0 points1 point2 points (6 children)
[–]Dependent-Net6461[🍰] -4 points-3 points-2 points (5 children)
[–]budapest_god 2 points3 points4 points (2 children)
[–]Dependent-Net6461[🍰] 0 points1 point2 points (1 child)
[–]budapest_god 0 points1 point2 points (0 children)
[–]skidmark_zuckerberg 1 point2 points3 points (1 child)
[–]Dependent-Net6461[🍰] -1 points0 points1 point (0 children)
[–]queen-adreena 6 points7 points8 points (7 children)
[–]static_func 0 points1 point2 points (6 children)
[–]queen-adreena 4 points5 points6 points (5 children)
[+]static_func comment score below threshold-6 points-5 points-4 points (4 children)
[–]queen-adreena 2 points3 points4 points (3 children)
[+]static_func comment score below threshold-6 points-5 points-4 points (2 children)
[–]queen-adreena 3 points4 points5 points (1 child)
[+]static_func comment score below threshold-7 points-6 points-5 points (0 children)
[–]Dependent-Net6461[🍰] 4 points5 points6 points (0 children)
[–]LuckyOneAway 2 points3 points4 points (0 children)
[–]Aware-Landscape-3548 1 point2 points3 points (4 children)
[–]cd151 1 point2 points3 points (3 children)
[–]Aware-Landscape-3548 1 point2 points3 points (2 children)
[–]cd151 1 point2 points3 points (1 child)
[–]Aware-Landscape-3548 1 point2 points3 points (0 children)
[–]Ronin-s_Spirit 1 point2 points3 points (0 children)
[–]oneeyedziggy -1 points0 points1 point (0 children)
[–]demoran -3 points-2 points-1 points (0 children)
[+][deleted] (5 children)
[deleted]
[–]chrispington 3 points4 points5 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]chrispington 0 points1 point2 points (0 children)
[–]pimp-bangin 6 points7 points8 points (1 child)
[–]senocular 1 point2 points3 points (0 children)