Made by Joakim Lindfors
Date: 2023-05-03
Course: Applications Development for Internet (5TF042)
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.
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:
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.
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.
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.
Even though TypeScript is a superset of JavaScript, there are still some drawbacks to using TypeScript instead of pure JavaScript.