Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
Lessons:14Length:1.2 hours

Next lesson playing in 5 seconds

  • Overview
  • Transcript

1.2 What Is TypeScript?

Hi and welcome back to TypeScript Fundamentals. In this lesson, I'm giving you an introduction about what TypeScript really is and how it relates to the classic JavaScript. TypeScript is developed and maintained by Microsoft. It was first released in October 2012. TypeScript was intended for large scale web applications. These are based on JavaScript. So what makes it better? Well, first of all, TypeScript is just a superset of JavaScript. This means that any valid JavaScript code is also valid TypeScript code, then there are three major areas where TypeScript aims to improve JavaScript. The first concept is the one of strong typing, also known as static typing. If you come from languages like Java or any C-like language, you already know what this is. Strong typing requires you to specify a type for every variable or parameter you define and it ensures that only this type is used during a compilation step called type checking. This feature is optional in TypeScript, so you don't have to use it, but it makes debugging a lot easier. If the compiler can help you avoid mistakes, because of a wrong type. The second enhancement TypeScript makes to JavaScript is the extension of object-oriented functionality like clauses, interfaces, generics and so on. Some of those features though, they creep into newer versions of the ECMAScript specification. But on to browser support them and user's upgrade to a newer browser versions, it takes time, a lot of time. Especially big companies are very, very reluctant to upgrade to new possibly untested versions of web browsers. In grouping number three is the fact that by using a compiler and strict to constraints in typing, you can catch errors at compile-time instead of run-time which is usually the case with interpreted languages like JavaScript, Ruby or Python. With interpreted languages, you have the problem that until you run a certain piece of code, you don't know how it behaves or if there is an error beforehand. I've called it a compiler so far, because that is the much more common term for transforming a piece of code into another one. But technically, the word transpiler would be more appropriate. It is used when the compilation is from an input language that is very similar to the output language. So if you see the terms transpiling or transpiler somewhere, you now know that this basically means the same as compiling or a compiler. Of course, if you use a strongly typed language and want to integrate it with popular libraries like JQuery, MongoDB, D3 or even basic modules, you can run into problems when there is no type information available for them as they are written in plain old JavaScript. Much like in other languages like C++, you can have header files that define types for those, so you are all set. As you can see, there are a couple of advantages to using plain old JavaScript, especially when using TypeScript in a bigger project that uses a packager like web pack. Of course, with ECMAScript evolving every year, the differences get smaller over time, although static typing will at least take a couple of years until it will be added to the specification. To recap, TypeScript is a superset of JavaScript. It supports strong or static typing for variables, function parameters and return values. TypeScript extends JavaScript's object-oriented capabilities. By having compile time errors, less run-time errors should occur. Because of the jacks, the compiler makes you run this step. Now it's time to install the TypeScript compiler and write our first TypeScript program. We will do that in the next lesson. See you there.

Back to the top