Codementor Events

How I learned TypeScript

Published Mar 21, 2018Last updated Sep 17, 2018
How I learned TypeScript

About me

I am an engineer with front and back end JavaScript experience. I come from a background of HTML/CSS/JS, and have enjoyed watching the explosive growth of web software.

Why I wanted to learn TypeScript

I had to learn TypeScript for a job I had gotten, and I was quickly motivated to include it in all of my projects, big and small. I had been developing exclusively in JavaScript, and when I found that TypeScript could easily answer the constant question of "What was the name of the property I'm using?" I fell in love with it.

How I approached learning TypeScript

I started using TypeScript in the context of building an Angular2 application, but quickly found that it was easier to wrap my head around it from the server side by making Node scripts.

At first, I just watching youtube videos and reading the TypeScript docs (http://www.typescriptlang.org/docs/home.html), and found that you can get started by just installing typescript with npm and making a 'myScript.ts' file. From there, I experimented with the type system, the import system, and the magic of interfaces in JavaScript. It felt like I was finally able to use what I had learned in university. An extremely helpful tool is the TypeScript online playground (http://www.typescriptlang.org/play/) where you can compile code live.

Challenges I faced

One of the biggest challenges I faced using TypeScript was moving from a single file to using a tsconfig.json to set up my projects. For some reason my editor would listen to some things but not others, and it generally felt like I didn't know what was going on when I copied and pasted other people's tsconfig files from the internet. The best thing I did to overcome that was to really dive deep into what the tsconfig does by reading the docs (http://www.typescriptlang.org/docs/handbook/tsconfig-json.html) and the schema definition (http://json.schemastore.org/tsconfig)

Key takeaways

The biggest takeaway I found from learning TypeScript was to focus on the process first and the outcome later. It is often easy to assume a green test or a successful compile means everything is working perfectly, but it is always better to understand why your changes worked.

I also understood how important it is to have a zero-consequence playground to try out ideas and test things before implementing them in the real codebase. This process saved me a lot of time and headache from having to set up a test environment to try an idea out when a perfectly good one existed already.

Tips and advice

I can't recommend learning TypeScript enough. It makes development for web, which has always been difficult, easier than ever. Having the type system is like adding incredible comments to your code all the time. It makes teamwork smoother, it makes tests more natural, and it makes your editor more useful.

Final thoughts and next steps

As a final thought, I'd like to learn more about languages that compile to JavaScript. Maybe Go is next?

Discover and read more posts from Elliot Plant
get started
post commentsBe the first to share your opinion
Show more replies