Typescript: First thoughts

Damien Cosset - Jun 19 '19 - - Dev Community

Introduction

Typescript is a typed superset of Javascript. Because it is a superset, any valid Javascript is therefore valid Typescript. Typescript aims to produce more secure Javscript code thanks to type-checking, interfaces, generics...

Typescript has gained a lot of popularity lately. In the last State of Javascript survey, the percentage of users claiming that they used Typescript and would use it again went from 20.6% in 2016 to 46.7% in 2018.

Personally, I've heard about Typescript, but never took the time to learn it. It was only a matter of time before I ended up working on a project already using Typescript. And the time has come...

Note: The following thoughts are only personal feelings. My experience with Typescript is limited. I will be glad to receive feedbacks from more experienced Typescript users 😉

Collection of thoughts

A different mindset?

After spending some time with Typescript, I felt that my approach had to be slighlty different from vanilla Javascript. I suddenly had to think about which types my variables were going to be.

I'll admit that certain questions rarely popped into my head before. Is this variable going to ALWAYS be a string? What type is this function going to return?...

Having to think about these things requires a little bit more preparation before I write my code, and different mindset.

Self-documentation

Code written is Typescript feels more documented, and once I got used to the syntax and knew what I was reading, I felt more confortable with the code other people wrote.

Obviously, this is highly dependent on the developer's efforts. You can write proper garbage with Typescript or elegant readable poetry with vanilla Javascript.

Conclusion

I'm honestly still conflicted about the utility of Typescript. I'm liking what I see so far, but I'll need to experiment more to have a clear opinion.

I'd love to have feedbacks from Typescript users.

  • How was your experience transitioning from vanilla Javascript?
  • Did you notice better quality in the code?
  • How did Typescript change the development type?
  • Do you notice a difference between using Typescript in small teams and bigger teams?

Happy coding 😊

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .