TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. This article aims to teach you the basics and fundamentals of TypeScript.
I recommend that you have a good understanding of OOP concepts and basic JavaScript before continuing on with this tutorial (so as to make the most of it).
Node.js is an open-source, cross-platform runtime environment for server-side JavaScript. Node.js is required to run JavaScript without browser support. Type the following command in the terminal window to install TypeScript:
$ npm install -g typescript
Typescript can be built on a plethora of development environments such as Visual Studio.
Syntax defines a set of rules for writing programs. Every language specification defines its own syntax. An example of typescript code:
var message:string = "Hello World"
console.log(message)
To compile your TypeScript file, enter the following command:
tsc app.ts
Then you can run it:
node app.js
A variable is like a little container to store data in. Variables are essential in TypeScript. In TypeScript, you need to specify the data type of a variable.
As in other programming languages, TypeScript contains the following data types:
Declaring & Initializing a variable
variableName:type = value;
An example:
var name:string = "Bryan";
#web-development #javascript #programming #typescript