Intro to TypeScript

George Gore
2 min readMar 25, 2018

This article is written for those who have a background in JavaScript and are new to the world of TypeScript. This article will talk a little bit about:

  1. what is TypeScript?
  2. What problems does TypeScript solve?
  3. What does TypeScript look like?

What is TypeScript?

TypeScript is a superset of vanilla JavaScript that is converted, or is compiled into JavaScript when being deployed.

It works across all browsers and OS’s, and is an open source language maintained by Microsoft. TypeScript is also incredibly well scaled, and is generally used because it is a static typed language, and also offers classes and interfaces.

What problems does TypeScript solve?

While there are many diverse ways to use TypeScript, one of its greatest features is that it is a static type language. This means, that when you compile your TypeScript to JavaScript, it will flag any type errors before you deploy your code. This ends up catching a lot of human error, and saves a lot of time debugging.

What does TypeScript look like?

It’s easiest to see how TypeScript works but seeing it in action! I’ll give you a couple examples below, and you can see where TypeScript comes in handy.

const barker = (dog: string) => {"Bark!, I'm " dog};

If you were to feed the function barker the string “Rex”. You would get “Bark! I’m Rex” after compiling.

If you were to feed it [1,2,3], during compilation you would receive the message:

error TS2345: Argument of type 'number[]' is not assignable to parameter of type 'string'.

This would save developers the need to find the type error later on during production, and is one of the reasons TypeScript is such a widely used library!

--

--