Intro to TypeScript

Vijay Kartha
The Startup
Published in
12 min readMay 29, 2019

--

So what is TypeScript you might ask? It’s another thing all the cool kids are using these days, so you’d better wise up and learn this thing too!

All jokes aside, TypeScript is a new way to write JavaScript, and one that is a bit more precise when it comes to declaring variables, functions, classes and more.

If you’ve ever used another language like C# or Java, you know that those languages are a bit more strict about variable declaration. This strict declaration is sometimes known as static typing. JavaScript, by default is a loosely typed language.

While this is okay in JavaScript:

str = "Hello World";
console.log(str);

It’s definitely not in C#, we aren’t being strict enough about the type:

str = "Hello World";
Console.WriteLine(str);

This fails in C# because we haven't given the variable declared, aka str a type. In most programming languages like C#, you need to specify if the variable being declared is of a type of Integer, Float, String, Boolean, Array, List or something else.

A type helps the program know what kind of space in memory to allocate for the variable being declared. In JavaScript, we can get away without declaring a type for the variable, because JavaScript’s engine behind the scenes manages our type and memory…

--

--