SlideShare a Scribd company logo
iFour Consultancy
TypeScript Fundamentals
https://www.ifourtechnolab.com/
Index
❏ Introduction
❏ What is TypeScript?
❏ Features of TypeScript
❏ Types
❏ Declaring Variables
❏ Arrow Functions
❏ Interfaces, Classes, Objects, Constructors
❏ Access Modifiers
❏ Properties
❏ Modules
https://www.ifourtechnolab.com/
❑Introduction
❏ TypeScript lets you write JavaScript the way you really want to.
❏ TypeScript is a typed superset of JavaScript that compiles to
plain JavaScript.
❏ TypeScript is pure object oriented with classes, interfaces and
statically typed like C# or Java.
❏ The popular JavaScript framework Angular 2.0 and Above are
written in TypeScript.
❏ Mastering TypeScript can help programmers to write object-
oriented programs and have them compiled to JavaScript, both
on server side and client side.
❏ You should have a good understanding of OOP concepts and
basic JavaScript
https://www.ifourtechnolab.com/
❑What is TypeScript?
❏ By definition, “TypeScript is JavaScript for application-scale
development.”
❏ TypeScript is a strongly typed, object oriented, compiled
language.
❏ It was designed by Anders Hejlsberg (designer of C#) at
Microsoft.
❏ TypeScript is both a language and a set of tools.
❏ TypeScript is a typed superset of JavaScript compiled to
JavaScript.
❏ In other words, TypeScript is JavaScript plus some additional
features.
https://www.ifourtechnolab.com/
❑Features of TypeScript
❏ TypeScript is just JavaScript.
❏ TypeScript supports other JS libraries.
❏ Compiled TypeScript can be consumed from any JavaScript code.
❏ TypeScript-generated JavaScript can reuse all of the existing JavaScript frameworks, tools, and libraries.
❏ JavaScript is TypeScript. (like .ts / .js)
❏ TypeScript is portable.
❏ TypeScript and ECMAScript
https://www.ifourtechnolab.com/
❑Types
❏ number : Double precision 64-bit floating point values. It can be used to represent both, integers and
fractions.
❏ string :Represents a sequence of Unicode characters
❏ boolean :Represents logical values, true and false
❏ void :Used on function return types to represent non-returning functions
❏ null :Represents an intentional absence of an object value.
❏ undefined :Denotes value given to all uninitialized variables
❏ User-defined types include
1. Enumerations (enums),
2. classes,
3. interfaces,
4. arrays, and
5. tuple.
https://www.ifourtechnolab.com/
❑Declaring Variables
var name: string = ”iFour";
var score1: number = 50;
var score2: number = 42.50
var sum = score1 + score2
Variable Declaration in TypeScript
TypeScript variables must follow
the JavaScript naming rules −
1. Variable names can contain
alphabets and numeric digits.
2. They cannot contain spaces
and special characters, except
the underscore (_) and the
dollar ($) sign.
3. Variable names cannot begin
with a digit.
https://www.ifourtechnolab.com/
❑Interfaces, Classes, Objects, Constructors
Syntax:
interface interface_name {
}
Example:
interface Person {
firstName: string,
lastName: string,
sayHi: () => string
}
customer: Person = {
firstName:“iFour",
lastName:“TechnoLab",
sayHi: ():string =>{return "Hi there"}
}
Syntax:
class class_name {
//class scope
}
Example:
class Car {
engine: string; //field
constructor(engine:string) { //constructor
this.engine = engine
}
disp():void { //function
console.log("Engine is : "+ this.engine)
}
}
var object_name = new class_name([ arguments ])
https://www.ifourtechnolab.com/
❑Arrow Functions
❏ Arrow function refers to anonymous functions in
programming.
❏ Arrow functions are a concise mechanism to represent
anonymous functions.
❏ There are 3 parts to a Arrow function −
1. Parameters − A function may optionally have parameters
2. The fat arrow notation/lambda notation (=>) − It is also called as
the goes to operator
3. Statements − represent the function’s instruction set
❏ It is an anonymous function expression that points to a single
line of code. Its syntax is as follows −
( [param1, parma2,…param n] )=>statement;
Example
var iFour= (x:number)=> {
x = 10 + x
console.log(x)
}
iFour(100);
https://www.ifourtechnolab.com/
❑Access Modifiers
❏ A class can control the visibility of its data members to members of other classes.
❏ This capability is termed as Data Hiding or Encapsulation.
❏ Object Orientation uses the concept of access modifiers or access specifiers to implement the concept
of Encapsulation.
❏ The access specifiers/modifiers define the visibility of a class’s data members outside its defining class.
1. Public
2. Private
3. Protected
https://www.ifourtechnolab.com/
❑Modules
❏ A module is designed with the idea to organize code written in TypeScript.
❏ Modules are broadly divided into −
1. Internal Modules
- Internal modules came in earlier version of Typescript.
- This was used to logically group classes, interfaces, functions into one unit and can be
exported in another module.
- This logical grouping is named namespace in latest version of TypeScript.
2. External Modules
- External modules in TypeScript exists to specify and load dependencies between multiple
external js files.
- If there is only one js file used, then external modules are not relevant.
https://www.ifourtechnolab.com/
❑Modules Examples
Internal Module Syntax (Old)
Syntax:
module iFourModule {
export function add(x, y) {
console.log(x+y);
}
}
Namespace Syntax (New)
Syntax:
namespace iFourModule {
export function add(x, y)
{ console.log(x + y);}
}
JavaScript generated in both cases are same
var iFourModule ;
(function (iFourModule) {
function add(x, y) {
console.log(x + y);
}
iFourModule .add = add;
})(iFourModule || (iFourModule = {}));
External Module
There are two scenarios for loading dependents js files from a single main JavaScript
file.
1. Client Side - RequireJs
2. Server Side - NodeJs
https://www.ifourtechnolab.com/
❑Ambient
❏ Ambient declarations are a way of telling the TypeScript compiler that the actual source code exists
elsewhere.
❏ When you are consuming a bunch of third party js libraries like jquery/angularjs/nodejs you can’t rewrite
it in TypeScript.
❏ Ensuring typesafety and intellisense while using these libraries will be challenging for a TypeScript
programmer.
❏ Ambient declarations help to seamlessly integrate other js libraries into TypeScript.
❏ Defining Ambients
Ambient declarations are by convention kept in a type declaration file with following extension (d.ts)
Example : iFour.d.ts
Syntax
declare module Module_Name {
}
https://www.ifourtechnolab.com/
Thank you
https://www.ifourtechnolab.com/
Type-Script-Fundamentals Type-Script-Fundamentals

More Related Content

PPTX
Typescript language extension of java script
michaelaaron25322
 
PPTX
TypeScript . the JavaScript developer best friend!
Alessandro Giorgetti
 
PPTX
Complete Notes on Angular 2 and TypeScript
EPAM Systems
 
PPTX
Module 2.pptx Angular JS FRAMEWORK WEBDEVELOPMENT
raman76530
 
PDF
TypeScript introduction to scalable javascript application
Andrea Paciolla
 
PPT
TypeScript.ppt LPU Notes Lecture PPT for 2024
manveersingh2k05
 
PPTX
TypeScript 101
rachelterman
 
PPTX
TypeScript Overview
Aniruddha Chakrabarti
 
Typescript language extension of java script
michaelaaron25322
 
TypeScript . the JavaScript developer best friend!
Alessandro Giorgetti
 
Complete Notes on Angular 2 and TypeScript
EPAM Systems
 
Module 2.pptx Angular JS FRAMEWORK WEBDEVELOPMENT
raman76530
 
TypeScript introduction to scalable javascript application
Andrea Paciolla
 
TypeScript.ppt LPU Notes Lecture PPT for 2024
manveersingh2k05
 
TypeScript 101
rachelterman
 
TypeScript Overview
Aniruddha Chakrabarti
 

Similar to Type-Script-Fundamentals Type-Script-Fundamentals (20)

PDF
Introduction to TypeScript
NexThoughts Technologies
 
PPTX
Typescript
Nikhil Thomas
 
PPTX
Typescript: Beginner to Advanced
Talentica Software
 
PDF
TYPESCRIPT.pdfgshshhsjajajsjsjjsjajajjajjj
sonidsxyz02
 
PDF
TypeScript Interview Questions PDF By ScholarHat
Scholarhat
 
PPTX
TypeScript: Basic Features and Compilation Guide
Nascenia IT
 
PPTX
The advantage of developing with TypeScript
Corley S.r.l.
 
PPTX
AngularConf2015
Alessandro Giorgetti
 
PPTX
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Malla Reddy University
 
PPTX
TypeScript intro
Ats Uiboupin
 
PPTX
Typescript ppt
akhilsreyas
 
PDF
TypeScript - An Introduction
NexThoughts Technologies
 
PPTX
Type script
Mallikarjuna G D
 
PPTX
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
PPTX
TypeScript
Udaiappa Ramachandran
 
PDF
Reasons to Use Typescript for Your Next Project Over Javascript.pdf
MobMaxime
 
PPTX
All You Need to Know About Type Script
Folio3 Software
 
PDF
TypeScript for Java Developers
Yakov Fain
 
PPTX
002. Introducere in type script
Dmitrii Stoian
 
PPTX
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScript
Wekoslav Stefanovski
 
Introduction to TypeScript
NexThoughts Technologies
 
Typescript
Nikhil Thomas
 
Typescript: Beginner to Advanced
Talentica Software
 
TYPESCRIPT.pdfgshshhsjajajsjsjjsjajajjajjj
sonidsxyz02
 
TypeScript Interview Questions PDF By ScholarHat
Scholarhat
 
TypeScript: Basic Features and Compilation Guide
Nascenia IT
 
The advantage of developing with TypeScript
Corley S.r.l.
 
AngularConf2015
Alessandro Giorgetti
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Malla Reddy University
 
TypeScript intro
Ats Uiboupin
 
Typescript ppt
akhilsreyas
 
TypeScript - An Introduction
NexThoughts Technologies
 
Type script
Mallikarjuna G D
 
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
Reasons to Use Typescript for Your Next Project Over Javascript.pdf
MobMaxime
 
All You Need to Know About Type Script
Folio3 Software
 
TypeScript for Java Developers
Yakov Fain
 
002. Introducere in type script
Dmitrii Stoian
 
TypeScript 1.6 - How I learned to Stop Worrying and Love JavaScript
Wekoslav Stefanovski
 
Ad

Recently uploaded (20)

PDF
SK07J-2 Komatsu Skid Steer Loader Parts Manual SK07JF20001-Up
Heavy Equipment Manual
 
PDF
125US 135US - Hitachi Service Manual.pdf
Service Repair Manual
 
PDF
NCHRP Report 672 Roundabouts: An Informational Guide
Forklift Trucks in Minnesota
 
PPTX
INTRODUCTION TO HUMAN RESOURCE MANAGEMEN
FahadBinImtiaz
 
PPTX
ict-project-publication-and-statistic-13.pptx
RoelBautista2
 
PPTX
Database management system is manager data
thakormitul730
 
PPTX
AIMS OBJECTIVES ajjsjsjsjejejejejejejejejj
IsaacAntwi15
 
PPT
MTR VISIT By Indian Railway - Very Important.ppt
abheeplay
 
PDF
D6E Volvo EW160C EW180C Engine SM Download
Service Repair Manual
 
PPTX
STRATEGIC HRM.pptxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
khushigulati2325
 
PDF
TD-9H KOMATSU BULLDOZER PARTS MANUAL P045501-P046274
Heavy Equipment Manual
 
PDF
Instant Download ec300dnl manual Volvo Excavator Manual.pdf
Service Repair Manual
 
PPTX
Have 10 Thousand Dollars Lying Around? You Can Buy Any One Of These Project Cars
jennifermiller8137
 
PDF
Volvo ew210c Specs Excavator Service Repair Manual.pdf
Service Repair Manual
 
PDF
Coco Robotics: From Dorm Rooms to Sidewalks
ricky228571
 
PPTX
托莱多大学文凭办理|办理UT毕业证i20购买学位证书电子版
xxxihn4u
 
PDF
Hitachi 130 EXCAVATOR Repair Manual Download
Service Repair Manual
 
PDF
Transform Your Lexus for the Trails with Expert Off-Road Customization Services
MW4 Outfitters
 
PDF
Reliable Solutions for Maserati Battery, Wiring, and Electronics Problems You...
Kruse Lucas Imports
 
PPTX
Detroit Business Travel Made Easy with Detroit DTW Cars
Detroit DTW Car
 
SK07J-2 Komatsu Skid Steer Loader Parts Manual SK07JF20001-Up
Heavy Equipment Manual
 
125US 135US - Hitachi Service Manual.pdf
Service Repair Manual
 
NCHRP Report 672 Roundabouts: An Informational Guide
Forklift Trucks in Minnesota
 
INTRODUCTION TO HUMAN RESOURCE MANAGEMEN
FahadBinImtiaz
 
ict-project-publication-and-statistic-13.pptx
RoelBautista2
 
Database management system is manager data
thakormitul730
 
AIMS OBJECTIVES ajjsjsjsjejejejejejejejejj
IsaacAntwi15
 
MTR VISIT By Indian Railway - Very Important.ppt
abheeplay
 
D6E Volvo EW160C EW180C Engine SM Download
Service Repair Manual
 
STRATEGIC HRM.pptxkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
khushigulati2325
 
TD-9H KOMATSU BULLDOZER PARTS MANUAL P045501-P046274
Heavy Equipment Manual
 
Instant Download ec300dnl manual Volvo Excavator Manual.pdf
Service Repair Manual
 
Have 10 Thousand Dollars Lying Around? You Can Buy Any One Of These Project Cars
jennifermiller8137
 
Volvo ew210c Specs Excavator Service Repair Manual.pdf
Service Repair Manual
 
Coco Robotics: From Dorm Rooms to Sidewalks
ricky228571
 
托莱多大学文凭办理|办理UT毕业证i20购买学位证书电子版
xxxihn4u
 
Hitachi 130 EXCAVATOR Repair Manual Download
Service Repair Manual
 
Transform Your Lexus for the Trails with Expert Off-Road Customization Services
MW4 Outfitters
 
Reliable Solutions for Maserati Battery, Wiring, and Electronics Problems You...
Kruse Lucas Imports
 
Detroit Business Travel Made Easy with Detroit DTW Cars
Detroit DTW Car
 
Ad

Type-Script-Fundamentals Type-Script-Fundamentals

  • 2. Index ❏ Introduction ❏ What is TypeScript? ❏ Features of TypeScript ❏ Types ❏ Declaring Variables ❏ Arrow Functions ❏ Interfaces, Classes, Objects, Constructors ❏ Access Modifiers ❏ Properties ❏ Modules https://www.ifourtechnolab.com/
  • 3. ❑Introduction ❏ TypeScript lets you write JavaScript the way you really want to. ❏ TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ❏ TypeScript is pure object oriented with classes, interfaces and statically typed like C# or Java. ❏ The popular JavaScript framework Angular 2.0 and Above are written in TypeScript. ❏ Mastering TypeScript can help programmers to write object- oriented programs and have them compiled to JavaScript, both on server side and client side. ❏ You should have a good understanding of OOP concepts and basic JavaScript https://www.ifourtechnolab.com/
  • 4. ❑What is TypeScript? ❏ By definition, “TypeScript is JavaScript for application-scale development.” ❏ TypeScript is a strongly typed, object oriented, compiled language. ❏ It was designed by Anders Hejlsberg (designer of C#) at Microsoft. ❏ TypeScript is both a language and a set of tools. ❏ TypeScript is a typed superset of JavaScript compiled to JavaScript. ❏ In other words, TypeScript is JavaScript plus some additional features. https://www.ifourtechnolab.com/
  • 5. ❑Features of TypeScript ❏ TypeScript is just JavaScript. ❏ TypeScript supports other JS libraries. ❏ Compiled TypeScript can be consumed from any JavaScript code. ❏ TypeScript-generated JavaScript can reuse all of the existing JavaScript frameworks, tools, and libraries. ❏ JavaScript is TypeScript. (like .ts / .js) ❏ TypeScript is portable. ❏ TypeScript and ECMAScript https://www.ifourtechnolab.com/
  • 6. ❑Types ❏ number : Double precision 64-bit floating point values. It can be used to represent both, integers and fractions. ❏ string :Represents a sequence of Unicode characters ❏ boolean :Represents logical values, true and false ❏ void :Used on function return types to represent non-returning functions ❏ null :Represents an intentional absence of an object value. ❏ undefined :Denotes value given to all uninitialized variables ❏ User-defined types include 1. Enumerations (enums), 2. classes, 3. interfaces, 4. arrays, and 5. tuple. https://www.ifourtechnolab.com/
  • 7. ❑Declaring Variables var name: string = ”iFour"; var score1: number = 50; var score2: number = 42.50 var sum = score1 + score2 Variable Declaration in TypeScript TypeScript variables must follow the JavaScript naming rules − 1. Variable names can contain alphabets and numeric digits. 2. They cannot contain spaces and special characters, except the underscore (_) and the dollar ($) sign. 3. Variable names cannot begin with a digit. https://www.ifourtechnolab.com/
  • 8. ❑Interfaces, Classes, Objects, Constructors Syntax: interface interface_name { } Example: interface Person { firstName: string, lastName: string, sayHi: () => string } customer: Person = { firstName:“iFour", lastName:“TechnoLab", sayHi: ():string =>{return "Hi there"} } Syntax: class class_name { //class scope } Example: class Car { engine: string; //field constructor(engine:string) { //constructor this.engine = engine } disp():void { //function console.log("Engine is : "+ this.engine) } } var object_name = new class_name([ arguments ]) https://www.ifourtechnolab.com/
  • 9. ❑Arrow Functions ❏ Arrow function refers to anonymous functions in programming. ❏ Arrow functions are a concise mechanism to represent anonymous functions. ❏ There are 3 parts to a Arrow function − 1. Parameters − A function may optionally have parameters 2. The fat arrow notation/lambda notation (=>) − It is also called as the goes to operator 3. Statements − represent the function’s instruction set ❏ It is an anonymous function expression that points to a single line of code. Its syntax is as follows − ( [param1, parma2,…param n] )=>statement; Example var iFour= (x:number)=> { x = 10 + x console.log(x) } iFour(100); https://www.ifourtechnolab.com/
  • 10. ❑Access Modifiers ❏ A class can control the visibility of its data members to members of other classes. ❏ This capability is termed as Data Hiding or Encapsulation. ❏ Object Orientation uses the concept of access modifiers or access specifiers to implement the concept of Encapsulation. ❏ The access specifiers/modifiers define the visibility of a class’s data members outside its defining class. 1. Public 2. Private 3. Protected https://www.ifourtechnolab.com/
  • 11. ❑Modules ❏ A module is designed with the idea to organize code written in TypeScript. ❏ Modules are broadly divided into − 1. Internal Modules - Internal modules came in earlier version of Typescript. - This was used to logically group classes, interfaces, functions into one unit and can be exported in another module. - This logical grouping is named namespace in latest version of TypeScript. 2. External Modules - External modules in TypeScript exists to specify and load dependencies between multiple external js files. - If there is only one js file used, then external modules are not relevant. https://www.ifourtechnolab.com/
  • 12. ❑Modules Examples Internal Module Syntax (Old) Syntax: module iFourModule { export function add(x, y) { console.log(x+y); } } Namespace Syntax (New) Syntax: namespace iFourModule { export function add(x, y) { console.log(x + y);} } JavaScript generated in both cases are same var iFourModule ; (function (iFourModule) { function add(x, y) { console.log(x + y); } iFourModule .add = add; })(iFourModule || (iFourModule = {})); External Module There are two scenarios for loading dependents js files from a single main JavaScript file. 1. Client Side - RequireJs 2. Server Side - NodeJs https://www.ifourtechnolab.com/
  • 13. ❑Ambient ❏ Ambient declarations are a way of telling the TypeScript compiler that the actual source code exists elsewhere. ❏ When you are consuming a bunch of third party js libraries like jquery/angularjs/nodejs you can’t rewrite it in TypeScript. ❏ Ensuring typesafety and intellisense while using these libraries will be challenging for a TypeScript programmer. ❏ Ambient declarations help to seamlessly integrate other js libraries into TypeScript. ❏ Defining Ambients Ambient declarations are by convention kept in a type declaration file with following extension (d.ts) Example : iFour.d.ts Syntax declare module Module_Name { } https://www.ifourtechnolab.com/

Editor's Notes

  • #1: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #2: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #3: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #4: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #5: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #6: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #7: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #8: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #9: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #10: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #11: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #12: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #13: Software Outsourcing Company India - http://www.ifourtechnolab.com/
  • #14: Software Outsourcing Company India - http://www.ifourtechnolab.com/