Name: Joakim Lindfors

Date: 2023-05-03

Course: Applications Development for Internet (5TF042)



Introduction

TypeScript is a programming language that is a superset of JavaScript, meaning that every valid JavaScript file is in turn also a valid TypeScript file. It is designed to make it easier to write and maintain large-scale JavaScript applications.

It adds features such as static typing, classes, interfaces, and modules, which are not available in JavaScript. In this beginner’s guide, we will explore some of the basic concepts of TypeScript.

Why Use TypeScript?

Benefits

There are a lot of reasons you might want to use TypeScript over plain JavaScript. These are some of the main benefits that TypeScript has to offer:

Static typing

Similar to other programming languages such as C#, C++, and Java, TypeScript uses static typing, meaning that variable types are determined during development. This helps prevent unexpected errors at runtime.

Code completion & Refactoring

Using static types also enables more code completion opportunities, as the editor will in a lot of cases know what type you are working with, and therefore can suggest more narrowed-down code completion.

The same goes for refactoring, as the code needs to be more strict and better structured, it allows for easier, automatic refactoring.

Faster development

Another benefit of TypeScript is faster updates and improvements. Since the code that runs in web browsers is pure JavaScript, it takes a longer time for new features to be added to JavaScript, as web browsers’ engines may need to be updated as well, to allow for this new feature. However, with TypeScript, new features can be added without breaking the runtime code in the browser.

Drawbacks