SlideShare a Scribd company logo
1 of 18
Sharif Rifat
TYPE SCRIPT
• JavaScript is not originally designed for large complex applications (mostly a scripting language, with
functional programming constructs), lacks structuring mechanisms like Class, Module, Interface.
• Typescript is a typed superset of JavaScript that compiles to plain JavaScript.
• Adds additional features like Static Type (optional), Class, Module etc. to JavaScript
• Microsoft technology.
• Open Source.
• Versions.
• First made public in October 2012.
• Latest version - Typescript 2.0.5.
What’s TypeScript?
• Static Typing: Due to the static typing, code written in TypeScript is more predictable,
and is generally easier to debug.
• OOP Support: Makes it easier to organize the code base for very large and complicated
apps cause of modules, namespaces and strong OOP support.
• Safer: TypeScript has a compilation step to JavaScript that catches all kinds of errors
before they reach runtime and break something.
• Code Editor Suggestion: Visual studio has the autocomplete suggestion for typescript.
Why TypeScript
• Any
• Any Type is a super set of all types
• var x : any;
• var y;
• Primitive
• Number
• Does not have separate integer and float/double type.
• var num : number = 20;
• var num = 20;
• String
• Both single quote or double quotes can be used.
• var name : string = “hello”;
• var name =’hello’;
• Bool
• var isOpen =true;
Type Annotation
• Void
• Used as the return type of functions that don’t return any value
• Object Types
• class, interface, module.
• Array
• Array types can be written in:
• var list: number[] = [1, 2, 3];
• var list: Array<number> = [1, 2, 3];
• var list:any[] = [1, true, "free"]
• Enum
• enum Color { Red, Green, Blue };
• var color = Color.Blue;
Type Annotation
• Tuple
• Tuple types allow you to express an array where the type of a fixed number of elements is known.
• var x: [string, number];
x = ['hello', 10];
Type Annotation
• Design time feature. No additional code is emitted in the final JavaScript that TypeScript compiler
produces.
• If there’s a type mismatch TypeScript shows a warning.
Type Annotation
• Type Annotation for parameter and return type.
• Optional and Default Parameter.
• https://www.typescriptlang.org/docs/handbook/functions.html
Functions
• Properties and fields to store data
• Methods to define behavior
Class
• TypeScript supports inheritance of class through extends keyword
• super keyword.
Inheritance
• Modules can be defined using module keyword.
• A module can contain sub module, class, interface or enum.
• Class, Interfaces , functions can be exposed using export keyword.
Module
• Declared using interface keyword
• TS compiler shows error when Interface signature and implementation does not match
• Optional properties can be declared for an interface (using ?)
Interface
• Able to create a component that can work over a variety of types rather than a single one.
function identity<T>(arg: T): T {
return arg;
}
• Type argument inference - we want the compiler to set the value of T for us automatically based on
the type of the argument we pass in.
Generics
• Decorators provide a way to add both annotations and a meta-programming syntax
for class declarations and members
Decorator
Using npm:
$ npm install typescript-compiler
The following command will compile a single .ts file in to a .js file:
$ tsc app.ts
To compile multiple .ts files:
$tsc app.ts another.ts someMore.ts
You can also use wildcards too. The following command will compile all TypeScript files
in the current folder.
$tsc *.ts
All TypeScript files will compile to their corresponding JavaScript files.
How to Compile
The presence of a tsconfig.json file in a directory indicates that the directory is the root
of a TypeScript project. The tsconfig.json file specifies the root files and the compiler
options required to compile the project. A project is compiled in one of the following
ways:
• By invoking tsc with no input files, in which case the compiler searches for the
tsconfig.json file starting in the current directory and continuing up the parent
directory chain.
• By invoking tsc with no input files and a --project (or just -p) command line option
that specifies the path of a directory containing a tsconfig.json file, or a path to a
valid .json file containing the configurations.
Using tsconfig.json:
• https://www.typescriptlang.org/
• https://www.typescriptlang.org/docs/tutorial.html
• Jhon Papa: https://johnpapa.net/typescriptpost1/
• Playground: http://basarat.com/TypeScriptEditor/
Some important Links
Thanks All

More Related Content

What's hot

What's hot (20)

TypeScript Best Practices
TypeScript Best PracticesTypeScript Best Practices
TypeScript Best Practices
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
 
TypeScript intro
TypeScript introTypeScript intro
TypeScript intro
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScript
 
Angular Observables & RxJS Introduction
Angular Observables & RxJS IntroductionAngular Observables & RxJS Introduction
Angular Observables & RxJS Introduction
 
Angular 2
Angular 2Angular 2
Angular 2
 
Angular 2 Essential Training
Angular 2 Essential Training Angular 2 Essential Training
Angular 2 Essential Training
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
JavaScript - Chapter 7 - Advanced Functions
 JavaScript - Chapter 7 - Advanced Functions JavaScript - Chapter 7 - Advanced Functions
JavaScript - Chapter 7 - Advanced Functions
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
 
TypeScript Seminar
TypeScript SeminarTypeScript Seminar
TypeScript Seminar
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
 

Similar to TypeScript: Basic Features and Compilation Guide

JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
Reagan Hwang
 

Similar to TypeScript: Basic Features and Compilation Guide (20)

Getting started with typescript and angular 2
Getting started with typescript  and angular 2Getting started with typescript  and angular 2
Getting started with typescript and angular 2
 
Compiler Construction
Compiler ConstructionCompiler Construction
Compiler Construction
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
 
Type script
Type scriptType script
Type script
 
Type script
Type scriptType script
Type script
 
Net framework
Net frameworkNet framework
Net framework
 
Angular2
Angular2Angular2
Angular2
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
Design Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best PracticesDesign Like a Pro: Scripting Best Practices
Design Like a Pro: Scripting Best Practices
 
Learning typescript
Learning typescriptLearning typescript
Learning typescript
 
c++ Unit III - PPT.pptx
c++ Unit III - PPT.pptxc++ Unit III - PPT.pptx
c++ Unit III - PPT.pptx
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Python ppt
Python pptPython ppt
Python ppt
 
Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
 
The Philosophy of .Net
The Philosophy of .NetThe Philosophy of .Net
The Philosophy of .Net
 
C#
C#C#
C#
 
CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)CS4443 - Modern Programming Language - I Lecture (1)
CS4443 - Modern Programming Language - I Lecture (1)
 
INTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c languageINTRODUCTION TO C PROGRAMMING in basic c language
INTRODUCTION TO C PROGRAMMING in basic c language
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
 

More from Nascenia IT

More from Nascenia IT (20)

AI Tools for Productivity: Exploring Prompt Engineering and Key Features
AI Tools for Productivity: Exploring Prompt Engineering and Key FeaturesAI Tools for Productivity: Exploring Prompt Engineering and Key Features
AI Tools for Productivity: Exploring Prompt Engineering and Key Features
 
Introduction to basic data analytics tools
Introduction to basic data analytics toolsIntroduction to basic data analytics tools
Introduction to basic data analytics tools
 
Communication workshop in nascenia
Communication workshop in nasceniaCommunication workshop in nascenia
Communication workshop in nascenia
 
The Art of Statistical Deception
The Art of Statistical DeceptionThe Art of Statistical Deception
The Art of Statistical Deception
 
করোনায় কী করি!
করোনায় কী করি!করোনায় কী করি!
করোনায় কী করি!
 
GDPR compliance expectations from the development team
GDPR compliance expectations from the development teamGDPR compliance expectations from the development team
GDPR compliance expectations from the development team
 
Writing Clean Code
Writing Clean CodeWriting Clean Code
Writing Clean Code
 
History & Introduction of Neural Network and use of it in Computer Vision
History & Introduction of Neural Network and use of it in Computer VisionHistory & Introduction of Neural Network and use of it in Computer Vision
History & Introduction of Neural Network and use of it in Computer Vision
 
Ruby on Rails: Coding Guideline
Ruby on Rails: Coding GuidelineRuby on Rails: Coding Guideline
Ruby on Rails: Coding Guideline
 
iphone 11 new features
iphone 11 new featuresiphone 11 new features
iphone 11 new features
 
Software quality assurance and cyber security
Software quality assurance and cyber securitySoftware quality assurance and cyber security
Software quality assurance and cyber security
 
Job Market Scenario For Freshers
Job Market Scenario For Freshers Job Market Scenario For Freshers
Job Market Scenario For Freshers
 
Modern Frontend Technologies (BEM, Retina)
Modern Frontend Technologies (BEM, Retina)Modern Frontend Technologies (BEM, Retina)
Modern Frontend Technologies (BEM, Retina)
 
CSS for Developers
CSS for DevelopersCSS for Developers
CSS for Developers
 
Big commerce app development
Big commerce app developmentBig commerce app development
Big commerce app development
 
Integrating QuickBooks Desktop with Rails Application
Integrating QuickBooks Desktop with Rails ApplicationIntegrating QuickBooks Desktop with Rails Application
Integrating QuickBooks Desktop with Rails Application
 
Shopify
ShopifyShopify
Shopify
 
Clean code
Clean codeClean code
Clean code
 
Ruby conf 2016 - Secrets of Testing Rails 5 Apps
Ruby conf 2016 - Secrets of Testing Rails 5 AppsRuby conf 2016 - Secrets of Testing Rails 5 Apps
Ruby conf 2016 - Secrets of Testing Rails 5 Apps
 
COREXIT: Microsoft’s new cross platform framework
COREXIT: Microsoft’s new cross platform frameworkCOREXIT: Microsoft’s new cross platform framework
COREXIT: Microsoft’s new cross platform framework
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

TypeScript: Basic Features and Compilation Guide

  • 2. • JavaScript is not originally designed for large complex applications (mostly a scripting language, with functional programming constructs), lacks structuring mechanisms like Class, Module, Interface. • Typescript is a typed superset of JavaScript that compiles to plain JavaScript. • Adds additional features like Static Type (optional), Class, Module etc. to JavaScript • Microsoft technology. • Open Source. • Versions. • First made public in October 2012. • Latest version - Typescript 2.0.5. What’s TypeScript?
  • 3. • Static Typing: Due to the static typing, code written in TypeScript is more predictable, and is generally easier to debug. • OOP Support: Makes it easier to organize the code base for very large and complicated apps cause of modules, namespaces and strong OOP support. • Safer: TypeScript has a compilation step to JavaScript that catches all kinds of errors before they reach runtime and break something. • Code Editor Suggestion: Visual studio has the autocomplete suggestion for typescript. Why TypeScript
  • 4. • Any • Any Type is a super set of all types • var x : any; • var y; • Primitive • Number • Does not have separate integer and float/double type. • var num : number = 20; • var num = 20; • String • Both single quote or double quotes can be used. • var name : string = “hello”; • var name =’hello’; • Bool • var isOpen =true; Type Annotation
  • 5. • Void • Used as the return type of functions that don’t return any value • Object Types • class, interface, module. • Array • Array types can be written in: • var list: number[] = [1, 2, 3]; • var list: Array<number> = [1, 2, 3]; • var list:any[] = [1, true, "free"] • Enum • enum Color { Red, Green, Blue }; • var color = Color.Blue; Type Annotation
  • 6. • Tuple • Tuple types allow you to express an array where the type of a fixed number of elements is known. • var x: [string, number]; x = ['hello', 10]; Type Annotation
  • 7. • Design time feature. No additional code is emitted in the final JavaScript that TypeScript compiler produces. • If there’s a type mismatch TypeScript shows a warning. Type Annotation
  • 8. • Type Annotation for parameter and return type. • Optional and Default Parameter. • https://www.typescriptlang.org/docs/handbook/functions.html Functions
  • 9. • Properties and fields to store data • Methods to define behavior Class
  • 10. • TypeScript supports inheritance of class through extends keyword • super keyword. Inheritance
  • 11. • Modules can be defined using module keyword. • A module can contain sub module, class, interface or enum. • Class, Interfaces , functions can be exposed using export keyword. Module
  • 12. • Declared using interface keyword • TS compiler shows error when Interface signature and implementation does not match • Optional properties can be declared for an interface (using ?) Interface
  • 13. • Able to create a component that can work over a variety of types rather than a single one. function identity<T>(arg: T): T { return arg; } • Type argument inference - we want the compiler to set the value of T for us automatically based on the type of the argument we pass in. Generics
  • 14. • Decorators provide a way to add both annotations and a meta-programming syntax for class declarations and members Decorator
  • 15. Using npm: $ npm install typescript-compiler The following command will compile a single .ts file in to a .js file: $ tsc app.ts To compile multiple .ts files: $tsc app.ts another.ts someMore.ts You can also use wildcards too. The following command will compile all TypeScript files in the current folder. $tsc *.ts All TypeScript files will compile to their corresponding JavaScript files. How to Compile
  • 16. The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project. A project is compiled in one of the following ways: • By invoking tsc with no input files, in which case the compiler searches for the tsconfig.json file starting in the current directory and continuing up the parent directory chain. • By invoking tsc with no input files and a --project (or just -p) command line option that specifies the path of a directory containing a tsconfig.json file, or a path to a valid .json file containing the configurations. Using tsconfig.json:
  • 17. • https://www.typescriptlang.org/ • https://www.typescriptlang.org/docs/tutorial.html • Jhon Papa: https://johnpapa.net/typescriptpost1/ • Playground: http://basarat.com/TypeScriptEditor/ Some important Links

Editor's Notes

  1. TypeScript compiler, named tsc, iswritten in TypeScript that can be compiled into regular JavaScript that can be executed in any JavaScript engine in any host. Typescript 0.9, released in 2013, added support for generics Typescript 1.0 was released at Build 2014
  2. All numbers in Typescript are floating point values. These floating point numbers get the type 'number'.
  3. automatic semicolon insertion
  4. -we can also pass functions in functions as arguments - Rest Parameters and arrow functions