We will the basics of TypeScript in this blog post.
This is part of the Typescript Tutorial Series, whose index / TOC is available here → Typescript Tutorial Series.
What is TypeScript
TypeScript is a superset of
static type checking,
OOP Style programming such
It is a new language created by Microsoft and has been widely used in the Frontend Technology like
Angular. In fact Angular 2 Framework was entirey rewritten in Typescript, from its predecessor version
Typescript Execution Flow
In simple terms, the execution flow of a Typescript program is described in 3 steps as follows. The
- Source → The Soure code is written in any compatible text editor or IDE with an extension
What you need to work with Typescript
You need to have the following to work with Typescript.
||https://npmjs.org/||Node Package Manager to install the typescript via
||http://typescriptlang.org||Typescript to transpile the program from the
Command Execution Example
If we have a Helloworld Program in TypeScript, the code execution goes like this.
# Source code written in `helloworld.ts` # Transpile this program using the `tsc` - TypeScript compiler tsc helloworld.ts # Run the `.js` version of the Program using the Node node helloworld.js
Source Code →
typescriptPractices > type helloworld.ts console.log("Hello World!");
typescriptPractices > tsc myhelloworld.ts typescriptPractices > ls -l total 8 -rw-rw-rw- 1 raghs 0 30 2021-06-18 22:20 helloworld.js -rw-rw-rw- 1 raghs 0 28 2021-06-18 22:18 helloworld.ts
Execute → using
node of the
.js file generated
typescriptPractices > node helloworld.js Hello World! typescriptPractices >
Raghavan alias Saravanan Muthu
19 Jun 2021 | Sat | 16 37 51 PM IST