SlideShare a Scribd company logo
TypeScript
Angular's Secret Weapon
Laurent Duveau
TypeScript
Angular's Secret Weapon
Laurent Duveau
Laurent Duveau
@LaurentDuveau
http://angular.ac/blog
Microsoft MVP and RD
• TypeScript ?
• Weapons
Types
Classes
Interfaces
Enums
• Tooling
• Generics
• Future
Agenda
TypeScript?
Wait...
Why TypeScript?
JavaScript
The Good
• It’s everywhere
• Huge amount of
libraries
• Flexible
The Bad
• Dynamic typing
• Lack of modularity
• Verbose patterns
(IIFE)
In short: JavaScript development scales badly.
Wish list
 Scalable HTML5 clientside development
 Modular code
 Easily learnable for Java or C# developers
 Non-invasive (existing libs, browser support)
 Long-term vision
 Clean Js output (exit strategy)
TypeScript!
 Scalable HTML5 clientside development
 Modular code
 Easily learnable for Java or C# developers
 Non-invasive (existing libs, browser support)
 Long-term vision
 Clean Js output (exit strategy)
“TypeScript? It’s like
coding JavaScript but
without the pain”
- Someone on Hacker News
TypeScript
TypeScript
• Open Source
• https://github.com/Microsoft/TypeScript
• Apache License 2.0
Who's No. 1 in open source?
Microsoft!
Source:
https://octoverse.github.com/
What is TypeScript?
• TypeScript is a typed superset of JavaScript that
compiles to plain JavaScript
• Any browser. Any host. Any OS
• Any valid JavaScript is valid Typescript
Visual Studio 2015: NuGet
Visual Studio 2017: built-in
Visual Studio Code: built-in
> npm install -g typescript
TypeScript
ES2016
ES2015
ES5
How Does TypeScript Work?
TypeScript
file.ts
JavaScript
file.js
TypeScript Compiler
Output ES5/ES6/…
compliant code
“Transpiling”
Type Support
TypeScript Types
Core types (optional but very helpful):
• string
• number
• boolean
• Date
• Array
• any
Custom types
TypeScript Type Annotations
name: string;
age: number;
isEnabled: boolean;
pets: string[];
accessories: string | string[];
Why Use Types?
@Component({...})
export class CalculatorComponent implements OnInit {
total: number = 0;
add(x: number, y: number) : number {
return x + y;
}
}
ngOnInit() {
this.total = this.add('26', 20);
}
Oops!
Errors at compile-time!
var a = 54
a.trim()
TypeError:
undefined is not a
function
var a: string = 54
a.trim()
Cannot convert
‘number’ to ‘string’
JavaScript TypeScript
runtime… compile-time!
“It feels just like writing
JavaScript, but with a thin
layer of type annotations
that bring you the familiar
advantages of static
typing”
Types in Action
Classes
Class, ctor, public/private, prop
class Auto {
constructor(private _engine:string) {
}
get engine():string {
return this._engine;
}
set engine(val:string) {
this._engine = val;
}
start() {
console.log("Take off using: " + this._engine);
}
}
constructor
get/set property
blocks
method
Classes in Action
Interfaces
What is an Interface?
A code contract
Interface Example
var person: ICustomer = {
firstName: 'Dave',
};
interface ICustomer {
firstName: string;
lastName: string;
age?: number;
}
lastName: 'Johnson'
Valid! Satisfied contract.
Invalid! Didn't satisfy contract.
Interface are only for compiler, do not generate Js code
Interfaces in Action
Enums
Enum
enum Language {
TypeScript,
JavaScript,
C#
}
var lang = Language.C#;
var ts = Language[0]; // ts === “TypeScript”
Functions
Functions
function buildName(firstName: string, lastName?: string)
{
if (lastName)
return firstName + " " + lastName;
else
return firstName;
}
function buildName(firstName: string, lastName = "Doe")
{
return firstName + " " + lastName;
}
optional param
default param
Functions in Action
Tooling Support
Tooling Support Examples
Key Tooling Support Features
Code Help/
Intellisense
Refactoring Peek/Go To
Find
References
Tooling in Action
Generics
What are Generics?
Code Templates
What's a Code Template?
export class List<T> {
add(item: T) {...}
}
...
var custs = new List<ICustomer>();
custs.add({ firstName: 'Ted', lastName: 'James'});
custs.add(205); //not valid
List<T> can be used in many
different ways
Generics in Action
The Future Today
The Future Today
In 2016 decorators were an integral part of Angular
via TypeScript
…While still being a Proposal in the ES2016 spec
Use "future" features today:
async/await
Many more...
https://github.com/Microsoft/TypeScript/wiki/Roadmap
async/await demo
TypeScript Secret Weapon Review
Types Tooling Interfaces Generics
Future
Today
"Angular technically
doesn't require TypeScript
kind of like technically a
car doesn't require
brakes.“ – Joe Eames
Thanks!
Need Onsite Training?
Need Onsite training on Angular and TypeScript?
Contact me at training@angular.ac!

More Related Content

PPT
TypeScript Presentation
Patrick John Pacaña
 
PDF
Introduction to Angular for .NET Developers
Laurent Duveau
 
PPTX
Typescript ppt
akhilsreyas
 
PDF
Introduction to Angular for .NET Developers
Laurent Duveau
 
PPTX
Introducing type script
Remo Jansen
 
PDF
Introduction to TypeScript by Winston Levi
Winston Levi
 
PPTX
TypeScript intro
Ats Uiboupin
 
PPTX
TypeScript . the JavaScript developer best friend!
Alessandro Giorgetti
 
TypeScript Presentation
Patrick John Pacaña
 
Introduction to Angular for .NET Developers
Laurent Duveau
 
Typescript ppt
akhilsreyas
 
Introduction to Angular for .NET Developers
Laurent Duveau
 
Introducing type script
Remo Jansen
 
Introduction to TypeScript by Winston Levi
Winston Levi
 
TypeScript intro
Ats Uiboupin
 
TypeScript . the JavaScript developer best friend!
Alessandro Giorgetti
 

What's hot (20)

PPTX
TypeScript Overview
Aniruddha Chakrabarti
 
PDF
Power Leveling your TypeScript
Offirmo
 
PDF
TypeScript - An Introduction
NexThoughts Technologies
 
PPTX
Typescript in 30mins
Udaya Kumar
 
PPTX
Typescript Fundamentals
Sunny Sharma
 
PDF
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
PDF
Typescript for the programmers who like javascript
Andrei Sebastian Cîmpean
 
PDF
Getting Started with TypeScript
Gil Fink
 
PPTX
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
PPT
Learning typescript
Alexandre Marreiros
 
PPTX
AngularConf2015
Alessandro Giorgetti
 
PDF
TypeScript and Angular workshop
José Manuel García García
 
PPTX
TypeScript
Udaiappa Ramachandran
 
PDF
TypeScript Best Practices
felixbillon
 
PDF
TypeScript for Java Developers
Yakov Fain
 
PDF
Introduction to Angular for .NET Developers
Laurent Duveau
 
PPTX
TypeScript 101
rachelterman
 
PPTX
TypeScript - Silver Bullet for the Full-stack Developers
Rutenis Turcinas
 
PPTX
Type script - advanced usage and practices
Iwan van der Kleijn
 
TypeScript Overview
Aniruddha Chakrabarti
 
Power Leveling your TypeScript
Offirmo
 
TypeScript - An Introduction
NexThoughts Technologies
 
Typescript in 30mins
Udaya Kumar
 
Typescript Fundamentals
Sunny Sharma
 
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
Typescript for the programmers who like javascript
Andrei Sebastian Cîmpean
 
Getting Started with TypeScript
Gil Fink
 
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
Learning typescript
Alexandre Marreiros
 
AngularConf2015
Alessandro Giorgetti
 
TypeScript and Angular workshop
José Manuel García García
 
TypeScript Best Practices
felixbillon
 
TypeScript for Java Developers
Yakov Fain
 
Introduction to Angular for .NET Developers
Laurent Duveau
 
TypeScript 101
rachelterman
 
TypeScript - Silver Bullet for the Full-stack Developers
Rutenis Turcinas
 
Type script - advanced usage and practices
Iwan van der Kleijn
 
Ad

Viewers also liked (14)

PDF
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
Ontico
 
PPTX
Typescript tips & tricks
Ori Calvo
 
PDF
Angular 2 - Typescript
Nathan Krasney
 
PPTX
TypeScript
GetDev.NET
 
PDF
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
Micael Gallego
 
PDF
TypeScript Seminar
Haim Michael
 
PDF
Typescript + Graphql = <3
felixbillon
 
PDF
TypeScript Introduction
Dmitry Sheiko
 
PPTX
Why TypeScript?
FITC
 
PDF
Александр Русаков - TypeScript 2 in action
MoscowJS
 
PPTX
002. Introducere in type script
Dmitrii Stoian
 
PPTX
Typescript
Nikhil Thomas
 
PDF
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
MoscowJS
 
PDF
TypeScriptで快適javascript
AfiruPain NaokiSoga
 
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
Ontico
 
Typescript tips & tricks
Ori Calvo
 
Angular 2 - Typescript
Nathan Krasney
 
TypeScript
GetDev.NET
 
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
Micael Gallego
 
TypeScript Seminar
Haim Michael
 
Typescript + Graphql = <3
felixbillon
 
TypeScript Introduction
Dmitry Sheiko
 
Why TypeScript?
FITC
 
Александр Русаков - TypeScript 2 in action
MoscowJS
 
002. Introducere in type script
Dmitrii Stoian
 
Typescript
Nikhil Thomas
 
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
MoscowJS
 
TypeScriptで快適javascript
AfiruPain NaokiSoga
 
Ad

Similar to TypeScript: Angular's Secret Weapon (20)

PDF
TypeScript: Angular's Secret Weapon
Laurent Duveau
 
PPTX
The advantage of developing with TypeScript
Corley S.r.l.
 
PPTX
concept of server-side JavaScript / JS Framework: NODEJS
Kongu Engineering College, Perundurai, Erode
 
PDF
Debugging an Angular App
Laurent Duveau
 
PPTX
Developer’s viewpoint on swift programming language
Azilen Technologies Pvt. Ltd.
 
PDF
Type script
srinivaskapa1
 
PDF
TypeScript, Dart, CoffeeScript and JavaScript Comparison
Haim Michael
 
PDF
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
PDF
An Introduction to TypeScript
WrapPixel
 
PDF
Using type script to build better apps
ColdFusionConference
 
PDF
Using type script to build better apps
devObjective
 
PDF
8.-Javascript-report powerpoint presentation
JohnLagman3
 
PPTX
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
Maarten Balliauw
 
PPTX
Typescript: JS code just got better!
amit bezalel
 
PPTX
What's coming to c# (Tel-Aviv, 2018)
Moaid Hathot
 
PDF
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
Sang Don Kim
 
PPTX
Type script
Zunair Shoes
 
PDF
Introduction to Angular for .NET Developers
Laurent Duveau
 
PPTX
Connecting C++ and JavaScript on the Web with Embind
Chad Austin
 
PPTX
TypeScript Introduction
Travis van der Font
 
TypeScript: Angular's Secret Weapon
Laurent Duveau
 
The advantage of developing with TypeScript
Corley S.r.l.
 
concept of server-side JavaScript / JS Framework: NODEJS
Kongu Engineering College, Perundurai, Erode
 
Debugging an Angular App
Laurent Duveau
 
Developer’s viewpoint on swift programming language
Azilen Technologies Pvt. Ltd.
 
Type script
srinivaskapa1
 
TypeScript, Dart, CoffeeScript and JavaScript Comparison
Haim Michael
 
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
An Introduction to TypeScript
WrapPixel
 
Using type script to build better apps
ColdFusionConference
 
Using type script to build better apps
devObjective
 
8.-Javascript-report powerpoint presentation
JohnLagman3
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
Maarten Balliauw
 
Typescript: JS code just got better!
amit bezalel
 
What's coming to c# (Tel-Aviv, 2018)
Moaid Hathot
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
Sang Don Kim
 
Type script
Zunair Shoes
 
Introduction to Angular for .NET Developers
Laurent Duveau
 
Connecting C++ and JavaScript on the Web with Embind
Chad Austin
 
TypeScript Introduction
Travis van der Font
 

More from Laurent Duveau (20)

PDF
Shit happens… debugging an Angular app.
Laurent Duveau
 
PDF
8 things you didn't know about the Angular Router, you won't believe #6!
Laurent Duveau
 
PDF
De 0 à Angular en 1h30! (french)
Laurent Duveau
 
PDF
Angular 6, CLI 6, Material 6 (french)
Laurent Duveau
 
PDF
Angular Advanced Routing
Laurent Duveau
 
PDF
Introduction to Angular with TypeScript for .NET Developers
Laurent Duveau
 
PDF
Introduction à Angular 2
Laurent Duveau
 
PDF
Angular 2... so can I use it now??
Laurent Duveau
 
PPTX
ngconf 2016 (french)
Laurent Duveau
 
PDF
Microsoft Edge pour les développeurs web
Laurent Duveau
 
PDF
Microsoft Edge pour les développeurs web
Laurent Duveau
 
PDF
Introduction to SPAs with AngularJS
Laurent Duveau
 
PDF
Xamarin.Forms [french]
Laurent Duveau
 
PDF
Back from Xamarin Evolve 2014
Laurent Duveau
 
PDF
Windows App Studio
Laurent Duveau
 
PDF
Windows 8: Live tiles, badges et notifications toasts [french]
Laurent Duveau
 
PPTX
L'opportunité Windows 8 pour les développeurs
Laurent Duveau
 
PPTX
Building apps for WP8 and Win8
Laurent Duveau
 
PPTX
Windows Store apps development
Laurent Duveau
 
PPTX
L'opportunité Windows 8: Introduction au Windows Store
Laurent Duveau
 
Shit happens… debugging an Angular app.
Laurent Duveau
 
8 things you didn't know about the Angular Router, you won't believe #6!
Laurent Duveau
 
De 0 à Angular en 1h30! (french)
Laurent Duveau
 
Angular 6, CLI 6, Material 6 (french)
Laurent Duveau
 
Angular Advanced Routing
Laurent Duveau
 
Introduction to Angular with TypeScript for .NET Developers
Laurent Duveau
 
Introduction à Angular 2
Laurent Duveau
 
Angular 2... so can I use it now??
Laurent Duveau
 
ngconf 2016 (french)
Laurent Duveau
 
Microsoft Edge pour les développeurs web
Laurent Duveau
 
Microsoft Edge pour les développeurs web
Laurent Duveau
 
Introduction to SPAs with AngularJS
Laurent Duveau
 
Xamarin.Forms [french]
Laurent Duveau
 
Back from Xamarin Evolve 2014
Laurent Duveau
 
Windows App Studio
Laurent Duveau
 
Windows 8: Live tiles, badges et notifications toasts [french]
Laurent Duveau
 
L'opportunité Windows 8 pour les développeurs
Laurent Duveau
 
Building apps for WP8 and Win8
Laurent Duveau
 
Windows Store apps development
Laurent Duveau
 
L'opportunité Windows 8: Introduction au Windows Store
Laurent Duveau
 

Recently uploaded (20)

PDF
Software Development Company | KodekX
KodekX
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPT
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
Software Development Company | KodekX
KodekX
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Smart Infrastructure and Automation through IoT Sensors
Rejig Digital
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 

TypeScript: Angular's Secret Weapon