7 Things You Need To Know About Typescript

TypeScript’s popularity has been on a steady increase over the last few years and it’s one of the most promising programming languages coming into the new year.

With around 60% of JavaScript programmers making the switch to TypeScript, and another 20% more wanting to dip their feet in and try, let’s talk about what all the fuss is about.

This is 7 things you need to know about TypeScript.

Historically, JavaScript has been the main language for scripting web pages and internet apps, also handy is the ability to use it on both the front and back end of frameworks like Node.js and Deno. That’s great and all, but the average webpage has evolved into a large, complex system that JavaScript just wasn’t designed to cope with.

Enter TypeScript.

Last year’s annual developer poll put it as the second most loved programming language amongst those surveyed, soaring to the seventh most used language on GitHub in just a few short years. Even Netflix has jumped on the bandwagon, announcing that all their user interface libraries would be running on TypeScript in the near future.

But why all the interest?

SO, WHAT IS IT:

If you were to make a Venn diagram, TypeScript would be the very big circle, with a smaller circle of JavaScript inside of it. Basically, TypeScript is a superset of plain Javascript, that adds static typing commands for use whenever you feel the need to.

Static typing helps with a whole heap of issues when navigating complex, large scale systems coded in JavaScript. It also makes refactoring code easy without breaking the system entirely and without running into hidden errors like the notorious “undefined is not a function”. Any programmers worth their salt have run into that one any number of times.

In fact, 15% of all JavaScript bugs can be detected with TypeScript. Dynamic typing can lead to bugs that can cause the server-side code to come grinding to a massive halt, but with TypeScript, the written aspect gives it a distinct edge when scaling up to the large code bases of commercial and business applications.

WHY USE IT?

  1. IT’S TYPED:

It’s not hard, just obvious. Type annotation in JavaScript is easier to understand and refactor, faster to implement, gives better performance, and allows for compile time safety. It’s a no brainer.

  1. GREAT DESIGN:

The language design is what makes TypeScript relatively unique amongst its peers. It’s a clean, elegant programming language that despite taking some time to learn, is fantastic to work in – comparable to things like Go, Kotlin, and Rust.

  1. DEVELOPMENT SCALING:

This is the big one. The productivity of teams will remain high, even when more teams are added to the project. There is a reason that TypeScript’s slogan is “JavaScript that scales” – large companies and bigger open-source projects are making the switch to TypeScript for a reason.

  1. DEVELOPER APPROVAL:

In short – developer’s love it. The stats don’t lie, based off the opinions of those working at the coal face and coding. Most staunch JavaScript members of the software community that try TypeScript stay with it after the initial learning phase – facts.

  1. GOING STRONG:

Excellent features aren’t enough to make a programming language popular. Scala and CoffeeScript gained huge initial popularity before fading away into relative obscurity. This won’t be a problem for TypeScript, as its growth hasn’t halted due to widespread adoption in the software industry – with over 12 million downloads per week, a figure that is constantly increasing.

  1. BIG BACKING:

TypeScript is open source, and backed by Google and Microsoft – that’s 2 out of the big 4 titans of the tech industry right there. With such a massive backing, and constant development and support from these two massive companies, there’s really no reason not to make the switch to what will be the most popular programming language in the not-too-distant future.

  1. SUPERSET OF JAVASCRIPT:

As we’ve already touched on, the killer feature of TypeScript is that in essence, it’s typed JavaScript with extra features. It added Class and Module support when JavaScript didn’t have them, and the recent trend is that JavaScript adds in features off the back of their implementation in TypeScript. Monkey see, monkey do.

THINGS TO LOOK OUT FOR:

  1. IT’S NEW:

Appreciate that even though you may be a JavaScript savant, TypeScript is a whole new skillset that you’ll have to spend the time to pick up. The key takeaway is not to beat yourself up if you run into problems due to an insufficient knowledge of the vocabulary of typed language. Recognize that there will be a difficult teething period, keep learning, and don’t beat yourself up about it too much.

  1. IT’S NOT ALL THE SAME:

Most tutorials and documentation will cover what you need to know about writing an application. The issue arises when you move on to library code – it’s a different can of worms. Getting TypeScript to work with React is significantly more complicated, and is another skillset in itself.

  1. DITCH THE HANDBOOK:

The official documentation is a nightmare to navigate. You’ll have a lot more joy if you seek out other resources that will help get you started faster. In particular, Shawn Wang’s React TypeScript Cheat Sheet is a godsend. Basarat’s guide to Typescript is also an excellent must read, and will hold your hand and take you through the basics.

  1. ASK FOR HELP:

Don’t be afraid to explore type helper libraries. Learn and leverage utility type language and methods to make your life a bit easier. Once you’ve mastered the syntax, there are powerful community-built packages to do away with the monotony of repeated code, leaving you to rely on things you’ve already defined and refactor your code.

  1. TOO HARD IS TOO HARD:

If you’re getting to a point where TypeScript becomes too complicated to type, then odds are you’re going to run into problems with design errors in your API. Flipping over a desk in frustration and yelling that something is impossible to type is a good indication that the syntax is too complicated, and that you should go back to the drawing board and take a look at the design of the function.

  1. USE TYPE GUARDS:

It might sound a bit counterintuitive, but running an extra type guard function is a pretty good idea. While you might be typing everything correctly, TypeScript can only check  what you’re physically writing and not any external data coming in. A guard will capture the error quite gracefully. Also, it allows you to narrow types inside of a function.

  1. GENERICS ARE AWESOME:

Generics are your friend. They’re a mashup of variables and function arguments, that have been transmogrified into a type system. They can be reused after they’re defined to refer their value, and can be set to help compute something for the user down the line. 

To put it simply, TypeScript is a great weapon for any programmer or developer to have in their arsenal. It’s easy to start small, learn as you go, and build up the knowledge necessary to master the more complex features.

So, don’t be afraid, embrace the moniker of novice, and give TypeScript a go. It’s pretty clear that it’s the programming language of the future, and will be adopted by more and more software and tech companies. It makes sense to move with the times, and besides – time and effort spent on expanding your skillset is never wasted.

TYPESCRIPT ENGINEER SALARIES

We’ve crunched the numbers on employee salaries in three major tech cities; San Francisco, New York City and Austin, Texas.

All our salary averages are base salary only, and don’t include startup equity or FAANG RSUs.

When it comes to software engineers specializing in TypeScript, programmers in San Francisco can expect to earn $123,000 per year with a range that extends past $150,000 per year.  Their counterparts in Austin can demand an average of $114,000 with senior TypeScript coders earning up to $138,000.   In the Big Apple, average base salary for Typescript programmers is an impressive $127,000 with larger salaries topping $166,000.

Kofi Group is proud to be a source of knowledge and insight into the startup software engineering world and offers a multitude of resources to help you learn more, improve your career, and help startups hire the best talent. If you are interested in learning more about what we do and how we can help you then get in touch or watch our Youtube videos for additional information.

Try our other blogs on coding, like  “The 10 Top Programming Languages of All Time” or “5 Reasons Why Go Is The Best Programming Language to Learn in 2021.”