2
10 Comments

Typescript ... just torture or a blessing in disguise?

Typescript can be seen as both torture and a blessing in disguise.

On the one hand, it offers an optional system that helps developers catch errors early and streamline development processes.

On the other hand, it can be challenging to learn for beginners and comes with its pitfalls.

I have a love-hate relationship with Typescripts, especially when I wanted to throw my laptop out of the window when I used to get stuck. Still, over time, it has grown on me. Now I don't wish to throw it out the window just want to punch it ... really hard :D

We are working on TS with React on our project UpEmbed. How is your experience with TS? And how many of you have actually thrown the laptop out the window xD

Typescript?
  1. Pure torture :@
  2. Almost a blessing O.o
Vote
  1. 2

    I think when you are new to Typescript I remember how hard it was. I called it was red squiggle driven development and it all seemed like it was adding needless overhead describing the data passed around the application. However once you start refactoring and making changes you suddenly realise how much you didn't know about your code...

    Renaming a function but its imported as different names throughout your code, changing the order of parameters to make a function consistent, changing a start field from a Date object to a unix timestamp... and the list goes on. With javascript you can change it and start to find and replace but you'll never be 100% certain you didn't miss a change and you created a (sometimes very) subtle bug, with Typescript you have very strong guarantees that your program works as intended going forward. You know there are typos of undefined variables and you know that if your changes have caused problems the code will simply not compile and it will tell you which things you forgot to update.

    Then add on that these type declarations represent a form of documentation that changes as the code changes and these docs are available in your IDE (hopefully) which means when you get perfect autocomplete for libraries and your own codebases. I rarely end up looking through docs for what params I need to pass in a TS codebase and going back feels so much slower!

    I hope you persevere and try this on a larger project because once past the knuckle you'll never want to go back to the uncertainly you don't currently realise is a constant problem in weakly typed codebases.

    1. 2

      You are absolutely right! It has been sometime since I created this post and I am starting to realise all of the things you've said.

      Typescript really is taking care of a lot of the blunders I would have made in code, specially in code refactoring aspect.

      1. 1

        These are blunders everyone makes I think and trusting the compiler is better than any find and replace skills anyone has. Things get even better with things like GraphQL codegen that builds typesafe API clients from your real API!

        1. 1

          I hadn't thought about that ... haha Typescript seems even more bearable now! :D

  2. 2

    Personally I would consider it torture to work in a project without Typescript.

    1. 1

      Haha, as we have progressed developing our product, I have come to the same conclusion! :D

  3. 1

    The only time TypeScript is torture is if you are in legacy code and converting it to TypeScript.
    I'm all for strongly typed code.
    TypeScript makes code more readable. Yes, your functions and variables all make sense now but come back to it in 6 months time and say that. TypeScript costs you time now to save you time in the future.

    1. 1

      Haha, yes you are right!

      But then there is also this debate on Typescript being slower than Javascript, what do you think about that?

      1. 1

        What do you mean by slower?
        Slower in development time? Yes, but you should save time in the long run if your project is large and a team are working on it.
        Slow in transpiling and during builds. Yes, but the time is so minuscule for most projects that it doesn't matter.
        If you are creating a small SPA or basic page you will never touch again, TypeScript will probably be a waste of time.
        If you are building a project that you hope to work on for a long time, grow, expand and have others working on it, I'd use TypeScript.

        1. 1

          Perfectly put!! I guess it is difficult in the start but soon it becomes a life saver.

Trending on Indie Hackers
Passed $7k 💵 in a month with my boring directory of job boards 57 comments How I got 1,000+ sign-ups in less than a month with social media alone 22 comments 87.7% of entrepreneurs struggle with at least one mental health issue 14 comments Are you wondering how to gain subscribers to a founder's X account from scratch? 9 comments Indie hackers selling to indie hackers? 7 comments Story of Iconbuddy from $0 to $6k per month in last 9 months 6 comments