DEV Community

Cover image for Typescript : Getting Started
Brandon Damue
Brandon Damue

Posted on

Typescript : Getting Started

Hello DEVs so excited to publish my very first post on
Let's get to it.

1. What is Typescript?

TypeScript is a strongly typed superset of Javascript that compiles to plain Javascript. Everything possible with pure javascript is available in typescript. TypeScript cannot run directly in the browser, instead the TypeScript code we write gets compiled into Javascript code, which can run directly in the browser. Typescript was released to the public in October of 2012 and it's popularity has been increasing since then. It is an open-source project hosted on under an Apache2 license. The use of typescript is widespread and it is not only used by it's creator Microsoft. It is also used by other tech giants like Google who have been using TypeScript since Angular 2 when they changed from MVC( Model-View-Controller ) architecture to a Component Based Architecture, Slack has migrated their JavasScript codebase to TypeScript, and other companies like Ubisoft, Asana, and Lyft are following suit. It is already smoothly integrated into Visual Studio, which makes it
easy to use without switching development tools.

2. Why use Typescript?

TypeScript provides many advantages for client-side developers. We are going to look at some reasons why you should use TypeScript.

  • TypeScript is simple, fast, and easy to learn since it is not an entirely new language.
  • TypeScript supports all Javascript libraries.
  • TypeScript is a safer approach to JavaScript.
  • TypeScript is statically typed, therefore code written in TypeScript is more predictable, and is generally easier to debug.
  • TypeScript supports OOP features like classes, inheritance, interfaces, generics etc.
  • TypeScript provides compile time error-checking.
  • TypeScript is portable, it can run on any environment Javascript runs on. It doesn’t need a VM or specific runtime environment.
  • TypeScript tooling provides autocompletion, type checking and source code documentation.

3. Using Typescript (Environment Setup)

To start a project with TypeScript, you need to have TypeScript installed and this is possible with the Node Package Manager, NPM. NPM must be installed and it comes free with the installation of NodeJS.

After installing NPM, write the following command in your Terminal / Command Prompt / Powershell to install TypeScript globally.

npm install -g typescript
Enter fullscreen mode Exit fullscreen mode

This will make the TypeScript compiler available for all your projects.
Type in the following command to test that TypeScript was installed successfully.

tsc --version
Enter fullscreen mode Exit fullscreen mode

If the installation was successful, you should see a version number similar to the one below.

version 4.0.2
Enter fullscreen mode Exit fullscreen mode
Setup Microsoft VS Code for TypeScript

Visual Studio Code includes TypeScript language support automatically. Because we already installed the TypeScript compiler, all we need to do is install VSCode.

If you’re having trouble installing VSCode, please see the official documentation for help.

Top comments (0)