Sunday, June 10, 2018

Variables in Typescript


  • TypeScript is the programming language.
  • TypeScript Introduced by microsoft.
  • Superset of JavaScript called as TypeScript.
  • TypeScript Follows OOPS.
  • Converting the TypeScript to Equalent JavaScript Called as "Transpilation".
  • Web Pages(HTML Files) won't understands th TypeScript.
  • As a TypeScript Developer we must perform the "Transpilation" Explicitely.
  • "tsc" is a compiler used to perform the transpilation.
  • "tsc" stands for "typescript compiler".



installation of TypeScript:
---------------------------
1) download and install NodeJS

website : https://nodejs.org/en/download/

file    : node-v8.11.2-x64.msi


2) download and install VisualStudioCode.

website : https://code.viGit-2.17.0-64-bitsualstudio.com/docs/?dv=win

file    : VSCodeSetup-x64-1.23.1.exe


3) download and install Git.

website : https://git-scm.com/download/win

file    : Git-2.17.0-64-bit.exe


4) install "tsc" by using following command.

> npm install -g tsc

- "npm" stands node packaging manager.

- "npm" is the integrated tool of NodeJS.

- "-g" stands for global installation.


variables in TypeScript:
------------------------
- Variables are used to store the data.
- By using Variables we can store all categories of Data.

Ex.
string
number
boolean
Array
Objects
  --
                          --
                          --

- we can declare variables by using either "var" keyword 
  or "let" keyword.

- we can save all the TypeScript files with the ".ts" extension.

- Transipilation gives the equalent javascript file.

Syntax.
------

var variable_name:data_type = "value"

Ex.
var data:string = "Welcome...!"


Transpilation of variables.ts file
----------------------------------

=> open the Integrated Terminal in Visual Studio Code

=> execute the following command in integrated terminal

> tsc variables.ts


create the webpage
------------------
index.html

<!DOCTYPE html>
<html>
<script src="variables.js"></script>
</html>

No comments:

Post a Comment