Introduction to TypesScript
Let's get an introduction to Typescript in this lesson.
We'll cover the following...
Introducing TypeScript
In programming, the type of some data indicates the set of values that are valid for that data. For example, if I say that a value is an integer, that means I expect the data to have a value like 1
, -3
, or 357
and not a value like "banana"
. If the data is set to a value that is not of the expected type, we expect something bad to happen. In some languages, the attempt to set data to the wrong value leads to a compiler error. Whereas in other languages, it leads to incorrect or unspecified behavior at runtime.
All high-level programming languages use some concept of type to determine behavior. This is to say that all these languages determine behavior by using not just the value of a piece of data in the system but also information about what kind of value it is.
TypeScript is a superset of JavaScript, which optionally allows you to add annotations to the code to specify type information. TypeScript includes a compilation step that enforces type consistency and converts valid TypeScript to JavaScript suitable for browsers.
The type system that TypeScript uses makes inferences about types based on the code, even if you do not explicitly provide type information. The goal of using TypeScript is to reduce code errors, first ...