SlideShare a Scribd company logo
TypeScript
Andrea Paciolla / @PaciollaAndrea
Andrea Paciolla / @PaciollaAndrea
Get in touch with me:
https://github.com/AndreaPaciolla
https://twitter.com/PaciollaAndrea
http://andreapaciolla.it
Frontend Engineer at ObjectWay
Agenda
1. Introduction
2. TypeScript, why?
3. Installation
4. Features
5. TypeScript Alternatives
6. Where TypeScript is used?
7. Conclusion
1. Introduction
TypeScript is...
TypeScript lets you write JavaScript the way
you really want to.
TypeScript is a typed superset of JavaScript
that compiles to plain JavaScript.
Any browser. Any host. Any OS. Open Source.
It follows the ECMAScript standards in any new versions
Overview
▷ Syntax based on ECMAScript 4 & ECMASCript 6 proposals
▷ TS is first and foremost a superset of JS
▷ Any regular Javascript is valid TypeScript Code
Well...
2. TypeScript,
why?
Main reasons to choose TypeScript are...
1. Compile time
2. Strong typing
3. Type definitions
4. Encapsulation
5. Private and public accessors
Compile time
JavaScript is an interpreted language errors are revealed at run time
TypeScript compiles your code errors are revealed at compile time
Strong Typing
Object oriented languages do not allow the type of a
variable to change – hence they are called strongly typed
languages.
The IDE can understand what type of variable you are
working with, and can bring better autocomplete or
Intellisense options
Type Definitions
- TypeScript uses files with a .d.ts extension as a sort of "header" file
- GitHub repository hosts definition files: DefinitelyTyped
Encapsulation
Through classes, is accomplished by either using the prototype pattern, or by
using the closure pattern.
Private and public accessors
A compile-time feature only Private variables are hidden outside of a class
JavaScript does not have private vars.
3. Installation
Get TypeScript setup
For more details check: https://www.typescriptlang.org/docs/tutorial.html
Via npm
$ npm install -g typescript
Visual Studio has a plugin
WebStorm has got built-in plugin
4. Features
TypeScript Features
● Data Types Supported
● Optional Static Type Annotation
● Classes
● Interface
● Namespace
● Arrow Expressions
● Type Assertions
● Ambient Declarations
● Source File Dependencies
Data Types
● Any (Just when we cannot get the right interface)
● Primitive (most of cases)
○ number
○ boolean
○ string
○ void
○ null
● Array (most of cases)
● Custom (we can define types by using interfaces)
Type Annotation
var a = 987;
a.trim();
// javascript error: typeError: a.trim is not a function on line xxx
var a = 987;
a.trim();
// Property 'trim' does not exist on type 'number'
var a:string = 123;
a.trim()
// cannot convert 'number' to 'string'
TypeScript Classes
● Can implement interfaces
● Inheritance
● Instance methods/members
● Static methods/members
● Single constructor
● Default/Optional parameter
● ES6 class syntax
TypeScript Classes
interface IComplexType {
name: string;
print(): string;
};
class ComplexType implements IComplexType {
name: string;
print(): string {
return "name:" + this.name;
}
};
var complexType: ComplexType = new ComplexType();
complexType.name = "complexType";
console.log(complexType.print()); // name:complexType
TypeScript Interfaces
● By convention they start with ‘I’ - e.g. IWebRTCPeer
● Used in classes with ‘implements’ keyword
● Used on typings context with semicolon syntax - e.g. let dot: IDot;
TypeScript Namespaces
// Used to group classes and interfaces under a common name
declare namespace WebRTCTypings {
interface IComplexType {
name: string;
print(): string;
};
}
var complexType: WebRTCTypings.ComplexType;
TypeScript Arrow Expressions
● Implicit return
● No braces for single expression
● Part of ES6
● Lexically scoped this
● You don't need to keep typing function
● It lexically captures the meaning of arguments
TypeScript Arrow Expressions Example
function(arg) {
return arg.toUpperCase;
}
// Arrow expression by using the fat arrow operator
(arg) => arg.toUpperCase();
TypeScript Type Assertions
TypeScript's type assertion are purely you telling the compiler that you know
about the types better than it does, and that it should not second guess you.
TypeScript Type Assertions Example
var foo = {};
foo.bar = 123; // error in js --> bar does not exist
// TS Way
interface IFoo {
bar: number;
}
var foo: IFoo;
foo.bar = 123;
TypeScript Ambient Declarations
A major design goal of TypeScript is to make easy the use of already existing
JavaScript libraries by using declarations.
TypeScript Source File
Get dependencies by using reference.
● Can be done using reference keyword
● Must be the first statement of file
● Paths are relative to the current file
● Can also be done using tsconfig file
5. TypeScript
Alternatives
TypeScript Alternatives?
TypeScript VS Dart / CoffeeScript
6. Where
TypeScript is
used?
Spread TS Worldwide
Typescript is being adopted by tons of
companies each day.
In particular, the Angular 2 adoption of TS is
spreading it more and more.
7. Conclusion
7. Conclusion
PROs
● Highly scalable
● Good for enterprise projects
● Solid abstraction of Ecma Standards
CONs
● Slow compiler
● Not enough d.ts (JS libraries are getting more and more)
● Not for libraries
Bonus
1. TSD vs Typings
2. Reference VS amd-dependency
3. Union Types
4. Function Overloads
5. Namespace instead of modules
That’s all! Thank you
Questions?
Get in touch with me:
https://github.com/AndreaPaciolla
https://twitter.com/PaciollaAndrea
http://andreapaciolla.it

More Related Content

What's hot (20)

PPTX
Typescript Fundamentals
Sunny Sharma
 
PPTX
TypeScript
Udaiappa Ramachandran
 
PPTX
Typescript ppt
akhilsreyas
 
PPTX
TypeScript Modules
Noam Kfir
 
PPTX
Typescript
Nikhil Thomas
 
PDF
Introduction to TypeScript by Winston Levi
Winston Levi
 
PPTX
TypeScript intro
Ats Uiboupin
 
PDF
TypeScript - An Introduction
NexThoughts Technologies
 
PPTX
Introducing type script
Remo Jansen
 
PDF
Typescript for the programmers who like javascript
Andrei Sebastian Cîmpean
 
PDF
Power Leveling your TypeScript
Offirmo
 
PPTX
Typescript in 30mins
Udaya Kumar
 
PPTX
TypeScript - Silver Bullet for the Full-stack Developers
Rutenis Turcinas
 
PPTX
All You Need to Know About Type Script
Folio3 Software
 
PPT
Learning typescript
Alexandre Marreiros
 
PPTX
Typescript 101 introduction
Bob German
 
PPTX
AngularConf2015
Alessandro Giorgetti
 
PPT
TypeScript Presentation
Patrick John Pacaña
 
DOC
Typescript Basics
Manikandan [M M K]
 
Typescript Fundamentals
Sunny Sharma
 
Typescript ppt
akhilsreyas
 
TypeScript Modules
Noam Kfir
 
Typescript
Nikhil Thomas
 
Introduction to TypeScript by Winston Levi
Winston Levi
 
TypeScript intro
Ats Uiboupin
 
TypeScript - An Introduction
NexThoughts Technologies
 
Introducing type script
Remo Jansen
 
Typescript for the programmers who like javascript
Andrei Sebastian Cîmpean
 
Power Leveling your TypeScript
Offirmo
 
Typescript in 30mins
Udaya Kumar
 
TypeScript - Silver Bullet for the Full-stack Developers
Rutenis Turcinas
 
All You Need to Know About Type Script
Folio3 Software
 
Learning typescript
Alexandre Marreiros
 
Typescript 101 introduction
Bob German
 
AngularConf2015
Alessandro Giorgetti
 
TypeScript Presentation
Patrick John Pacaña
 
Typescript Basics
Manikandan [M M K]
 

Similar to TypeScript introduction to scalable javascript application (20)

PPTX
typescript.pptx
ZeynepOtu
 
PPTX
Benefits of Typescript.pptx
AmitGupta440280
 
ODP
Getting started with typescript and angular 2
Knoldus Inc.
 
PPTX
TypeScript Introduction
Thanh Tai
 
PPTX
Type script is awesome
KeithMurgic
 
PPTX
Type script
Zunair Shoes
 
PDF
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
PDF
Introduction to TypeScript
NexThoughts Technologies
 
PPTX
Typescript language extension of java script
michaelaaron25322
 
PPTX
Type-Script-Fundamentals Type-Script-Fundamentals
ssuser742f291
 
PDF
Why Static Type Checking is Better
Andrew Rota
 
PDF
Type script
srinivaskapa1
 
PDF
Type Script Conceitos de ts para projetos front-end React - por ruben marcus
Ruben Marcus Luz Paschoarelli
 
PPTX
Typescript: Beginner to Advanced
Talentica Software
 
PDF
An Introduction to TypeScript
WrapPixel
 
PDF
TypeScript, Dart, CoffeeScript and JavaScript Comparison
Haim Michael
 
PPTX
Type script
Mallikarjuna G D
 
PPTX
Complete Notes on Angular 2 and TypeScript
EPAM Systems
 
PDF
TypeScript for Java Developers
Yakov Fain
 
PDF
TypeScript Interview Questions PDF By ScholarHat
Scholarhat
 
typescript.pptx
ZeynepOtu
 
Benefits of Typescript.pptx
AmitGupta440280
 
Getting started with typescript and angular 2
Knoldus Inc.
 
TypeScript Introduction
Thanh Tai
 
Type script is awesome
KeithMurgic
 
Type script
Zunair Shoes
 
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
Introduction to TypeScript
NexThoughts Technologies
 
Typescript language extension of java script
michaelaaron25322
 
Type-Script-Fundamentals Type-Script-Fundamentals
ssuser742f291
 
Why Static Type Checking is Better
Andrew Rota
 
Type script
srinivaskapa1
 
Type Script Conceitos de ts para projetos front-end React - por ruben marcus
Ruben Marcus Luz Paschoarelli
 
Typescript: Beginner to Advanced
Talentica Software
 
An Introduction to TypeScript
WrapPixel
 
TypeScript, Dart, CoffeeScript and JavaScript Comparison
Haim Michael
 
Type script
Mallikarjuna G D
 
Complete Notes on Angular 2 and TypeScript
EPAM Systems
 
TypeScript for Java Developers
Yakov Fain
 
TypeScript Interview Questions PDF By ScholarHat
Scholarhat
 
Ad

Recently uploaded (20)

PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Sound the Alarm: Detection and Response
VICTOR MAESTRE RAMIREZ
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
PDF
Deploy Faster, Run Smarter: Learn Containers with QNAP
QNAP Marketing
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PDF
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
PDF
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Modern Decentralized Application Architectures.pdf
Kalema Edgar
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
PDF
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
PDF
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Sound the Alarm: Detection and Response
VICTOR MAESTRE RAMIREZ
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
Deploy Faster, Run Smarter: Learn Containers with QNAP
QNAP Marketing
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
Hello I'm "AI" Your New _________________
Dr. Tathagat Varma
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Modern Decentralized Application Architectures.pdf
Kalema Edgar
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
How to Comply With Saudi Arabia’s National Cybersecurity Regulations.pdf
Bluechip Advanced Technologies
 
Understanding The True Cost of DynamoDB Webinar
ScyllaDB
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
2025 HackRedCon Cyber Career Paths.pptx Scott Stanton
Scott Stanton
 
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Ad

TypeScript introduction to scalable javascript application

  • 2. Andrea Paciolla / @PaciollaAndrea Get in touch with me: https://github.com/AndreaPaciolla https://twitter.com/PaciollaAndrea http://andreapaciolla.it Frontend Engineer at ObjectWay
  • 3. Agenda 1. Introduction 2. TypeScript, why? 3. Installation 4. Features 5. TypeScript Alternatives 6. Where TypeScript is used? 7. Conclusion
  • 5. TypeScript is... TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. Any browser. Any host. Any OS. Open Source. It follows the ECMAScript standards in any new versions
  • 6. Overview ▷ Syntax based on ECMAScript 4 & ECMASCript 6 proposals ▷ TS is first and foremost a superset of JS ▷ Any regular Javascript is valid TypeScript Code
  • 9. Main reasons to choose TypeScript are... 1. Compile time 2. Strong typing 3. Type definitions 4. Encapsulation 5. Private and public accessors
  • 10. Compile time JavaScript is an interpreted language errors are revealed at run time TypeScript compiles your code errors are revealed at compile time
  • 11. Strong Typing Object oriented languages do not allow the type of a variable to change – hence they are called strongly typed languages. The IDE can understand what type of variable you are working with, and can bring better autocomplete or Intellisense options
  • 12. Type Definitions - TypeScript uses files with a .d.ts extension as a sort of "header" file - GitHub repository hosts definition files: DefinitelyTyped
  • 13. Encapsulation Through classes, is accomplished by either using the prototype pattern, or by using the closure pattern.
  • 14. Private and public accessors A compile-time feature only Private variables are hidden outside of a class JavaScript does not have private vars.
  • 16. Get TypeScript setup For more details check: https://www.typescriptlang.org/docs/tutorial.html Via npm $ npm install -g typescript Visual Studio has a plugin WebStorm has got built-in plugin
  • 18. TypeScript Features ● Data Types Supported ● Optional Static Type Annotation ● Classes ● Interface ● Namespace ● Arrow Expressions ● Type Assertions ● Ambient Declarations ● Source File Dependencies
  • 19. Data Types ● Any (Just when we cannot get the right interface) ● Primitive (most of cases) ○ number ○ boolean ○ string ○ void ○ null ● Array (most of cases) ● Custom (we can define types by using interfaces)
  • 20. Type Annotation var a = 987; a.trim(); // javascript error: typeError: a.trim is not a function on line xxx var a = 987; a.trim(); // Property 'trim' does not exist on type 'number' var a:string = 123; a.trim() // cannot convert 'number' to 'string'
  • 21. TypeScript Classes ● Can implement interfaces ● Inheritance ● Instance methods/members ● Static methods/members ● Single constructor ● Default/Optional parameter ● ES6 class syntax
  • 22. TypeScript Classes interface IComplexType { name: string; print(): string; }; class ComplexType implements IComplexType { name: string; print(): string { return "name:" + this.name; } }; var complexType: ComplexType = new ComplexType(); complexType.name = "complexType"; console.log(complexType.print()); // name:complexType
  • 23. TypeScript Interfaces ● By convention they start with ‘I’ - e.g. IWebRTCPeer ● Used in classes with ‘implements’ keyword ● Used on typings context with semicolon syntax - e.g. let dot: IDot;
  • 24. TypeScript Namespaces // Used to group classes and interfaces under a common name declare namespace WebRTCTypings { interface IComplexType { name: string; print(): string; }; } var complexType: WebRTCTypings.ComplexType;
  • 25. TypeScript Arrow Expressions ● Implicit return ● No braces for single expression ● Part of ES6 ● Lexically scoped this ● You don't need to keep typing function ● It lexically captures the meaning of arguments
  • 26. TypeScript Arrow Expressions Example function(arg) { return arg.toUpperCase; } // Arrow expression by using the fat arrow operator (arg) => arg.toUpperCase();
  • 27. TypeScript Type Assertions TypeScript's type assertion are purely you telling the compiler that you know about the types better than it does, and that it should not second guess you.
  • 28. TypeScript Type Assertions Example var foo = {}; foo.bar = 123; // error in js --> bar does not exist // TS Way interface IFoo { bar: number; } var foo: IFoo; foo.bar = 123;
  • 29. TypeScript Ambient Declarations A major design goal of TypeScript is to make easy the use of already existing JavaScript libraries by using declarations.
  • 30. TypeScript Source File Get dependencies by using reference. ● Can be done using reference keyword ● Must be the first statement of file ● Paths are relative to the current file ● Can also be done using tsconfig file
  • 34. Spread TS Worldwide Typescript is being adopted by tons of companies each day. In particular, the Angular 2 adoption of TS is spreading it more and more.
  • 36. 7. Conclusion PROs ● Highly scalable ● Good for enterprise projects ● Solid abstraction of Ecma Standards CONs ● Slow compiler ● Not enough d.ts (JS libraries are getting more and more) ● Not for libraries
  • 37. Bonus 1. TSD vs Typings 2. Reference VS amd-dependency 3. Union Types 4. Function Overloads 5. Namespace instead of modules
  • 38. That’s all! Thank you Questions? Get in touch with me: https://github.com/AndreaPaciolla https://twitter.com/PaciollaAndrea http://andreapaciolla.it