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 Fundamentals
Typescript FundamentalsTypescript Fundamentals
Typescript Fundamentals
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Typescript in React: HOW & WHY?
Typescript in React: HOW & WHY?Typescript in React: HOW & WHY?
Typescript in React: HOW & WHY?
 
TypeScript
TypeScriptTypeScript
TypeScript
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the pain
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
 
Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practices
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
TypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptxTypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptx
 
Asp.net
Asp.netAsp.net
Asp.net
 
Object Oriented Javascript
Object Oriented JavascriptObject Oriented Javascript
Object Oriented Javascript
 
Asynchronous javascript
 Asynchronous javascript Asynchronous javascript
Asynchronous javascript
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Express
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
javaScript.ppt
javaScript.pptjavaScript.ppt
javaScript.ppt
 
Introduction for Master Class "Amazing Reactive Forms"
Introduction for Master Class "Amazing Reactive Forms"Introduction for Master Class "Amazing Reactive Forms"
Introduction for Master Class "Amazing Reactive Forms"
 

Similar to TypeScript: Basic Features and Compilation Guide

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
 
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
 
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
 

More from Nascenia IT

Introduction to basic data analytics tools
Introduction to basic data analytics toolsIntroduction to basic data analytics tools
Introduction to basic data analytics toolsNascenia IT
 
Communication workshop in nascenia
Communication workshop in nasceniaCommunication workshop in nascenia
Communication workshop in nasceniaNascenia IT
 
The Art of Statistical Deception
The Art of Statistical DeceptionThe Art of Statistical Deception
The Art of Statistical DeceptionNascenia IT
 
করোনায় কী করি!
করোনায় কী করি!করোনায় কী করি!
করোনায় কী করি!Nascenia IT
 
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 teamNascenia IT
 
Writing Clean Code
Writing Clean CodeWriting Clean Code
Writing Clean CodeNascenia IT
 
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 VisionNascenia IT
 
Ruby on Rails: Coding Guideline
Ruby on Rails: Coding GuidelineRuby on Rails: Coding Guideline
Ruby on Rails: Coding GuidelineNascenia IT
 
iphone 11 new features
iphone 11 new featuresiphone 11 new features
iphone 11 new featuresNascenia IT
 
Software quality assurance and cyber security
Software quality assurance and cyber securitySoftware quality assurance and cyber security
Software quality assurance and cyber securityNascenia IT
 
Job Market Scenario For Freshers
Job Market Scenario For Freshers Job Market Scenario For Freshers
Job Market Scenario For Freshers Nascenia IT
 
Modern Frontend Technologies (BEM, Retina)
Modern Frontend Technologies (BEM, Retina)Modern Frontend Technologies (BEM, Retina)
Modern Frontend Technologies (BEM, Retina)Nascenia IT
 
CSS for Developers
CSS for DevelopersCSS for Developers
CSS for DevelopersNascenia IT
 
Big commerce app development
Big commerce app developmentBig commerce app development
Big commerce app developmentNascenia IT
 
Integrating QuickBooks Desktop with Rails Application
Integrating QuickBooks Desktop with Rails ApplicationIntegrating QuickBooks Desktop with Rails Application
Integrating QuickBooks Desktop with Rails ApplicationNascenia IT
 
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 AppsNascenia IT
 
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 frameworkNascenia IT
 
An overview on the Reddot Ruby Conf 2016, Singapore
An overview on the Reddot Ruby Conf 2016, SingaporeAn overview on the Reddot Ruby Conf 2016, Singapore
An overview on the Reddot Ruby Conf 2016, SingaporeNascenia IT
 

More from Nascenia IT (20)

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
 
An overview on the Reddot Ruby Conf 2016, Singapore
An overview on the Reddot Ruby Conf 2016, SingaporeAn overview on the Reddot Ruby Conf 2016, Singapore
An overview on the Reddot Ruby Conf 2016, Singapore
 

Recently uploaded

What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 

Recently uploaded (20)

What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 

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