πŸ’‘πŸ€” Early Thoughts on TypeScript

twitter logo github logo Originally published at scottw.com on ・1 min read

I have not written enough TypeScript to know if I love it, hate it, or am just indifferent. In building my first small project, I found myself fumbling around the types and syntax quite a bit.

However, in just about every case, where I compiler complained about lack of type or an invalid type it saved me from code that likely would not have worked. Even better, the speed at which you receive the feedback is impressive.

twitter logo DISCUSS (4)
markdown guide
 

I’m really not a fan of JavaScript, it’s a bit too wishy washy and I always get annoyed trying to debug it. TypeScript is like a whole different world though.

Yeah the syntax is a bit clunky and the documentation could use a lot of work, but I actually enjoy writing it. To the point where I, for the first time, tried following some NodeJS tutorials which use TypeScript. None of them worked right for one reason or another so if anyone has a recommended one please link it! I’ve only written services in Python and want to branch out.

 

When I started TypeScript I absolutely hated it.

Now, I almost only code with it, you want to know why? Maintenance.

Statically typed languages are wonderfull to work with because when someone else get in your code, they know what it is going to do. Which is sometimes hard with vanilla JS.

I am not saying plug TypeScript everywhere even for a 1 event listener JS but you get me.

Also, TypeScript alongside a good naming convention and error handling makes for a wonderfull and reusable piece of web software :)

 

The way I like to do it is to get the code working with inferred types and then slowly start adding type declarations to inferred any to fixing any errors that show up.

Typescript is also good if your working with API. You can convert a JSON response to a interface using a website or vscode plugin and then have full typing for the API in you editor

 

When I started doing typescript I did everything as any when it throws error and when I didn't know the proper types (such as for react event handler types).

So I would just add that it OK to skip the type system in the beginning stage.

Classic DEV Post from Jan 20

What do you do to practice new programming languages and/or frameworks?

What to do to practice and learn new technologies when you don't have any creativity for projects?

Scott Watermasysk profile image
Boostrapped Founder. In to Ruby, Rails, JavaScript, VSCode, React, Tailwind, and more.