2. Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Join the session 5 minutes prior to
the session start time. We start on
time and conclude on time!
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Silent Mode
Keep your mobile devices in silent
mode, feel free to move out of
session in case you need to attend
an urgent call.
Avoid Disturbance
Avoid unwanted chit chat during
the session.
3. Our Agenda
01 Typescript:What and Why?
02 Assigning Types
03 Configuring Typescript
04 NodeJs and Typescript:SetUp
05 Demo
4. Typescript:What and Why?
● TypeScript is a very popular open-source language maintained and developed by
Microsoft.
● Basically TypeScript adds syntax on top of JavaScript, allowing developers to add
types.
Unwanted behaviour at runtime
Typescript add strict typing
Unwanted steps could be avoided
using strict types
You could add ‘if’ check to avoid
error.
5. Advantages of Typescript
In JavaScript, function parameters and variables don't have any information.
TypeScript allows specifying the types of data being passed around within the
code. Main Advantages of typescripts are:
● Strict typing
● Structural typing
● Type annotations
● Type inference
6. Typescript SetUp
We can install typescript using following command-
● sudo npm install -g typescript
● tsc {app.ts} <filename you want to compile>
‘tsc’ command is used to compile the ts file as javascript file.
Typescript Code
(Classes, interface,
Modules)
Typescript Compiler (
Target: ES5/ ES6)
Javascript File
7. Assigning Types
Cores Types are:-
number 1, 5.3, -10
All numbers,no differentiation
between integers or float
string
boolean
object
‘Anirudh’
true, false
{age:30}
All text values
just these two no ‘truthy’ or ‘falsy’
values
Any javascript objects more
specific type object are possible.
array [1, 2, 3]
Any javascript array type can be
flexible or strict.
8. Configuring Typescript
To initialize the Typescript project with Node.js, create a tsconfig.json file in the project root
directory.
→The config file stores the options for the Typescript compiler. Alternatively, you
can run tsc --init to automatically create this file in whatever directory you’re in.
command for configuring is :-
● tsc --init
here is an example of tsconfig file
9. NodeJs & Typescript: SetUp
commands to setup the NodeJs and Typescript:-
● tsc - - init
→to get the tsconfig.json file
● npm init
→to initialise and install the dependencies using npm
● npm install - -save express
→to save the express dependencies as we work with express package
● npm install - -save body-parser
→to parse the body in middleware.
● npm install - - save-dev @types/node