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

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
 

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
TypeScript: Basic Features and Compilation Guide
Nascenia IT
 
PPTX
Type script
Zunair Shoes
 
PPTX
Typescript language extension of java script
michaelaaron25322
 
PPT
TypeScript.ppt LPU Notes Lecture PPT for 2024
manveersingh2k05
 
PDF
TypeScript Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
Reasons to Use Typescript for Your Next Project Over Javascript.pdf
MobMaxime
 
PPTX
Complete Notes on Angular 2 and TypeScript
EPAM Systems
 
PDF
Getting Started with the TypeScript Language
Gil Fink
 
PPTX
typescript.pptx
ZeynepOtu
 
PDF
Introduction to TypeScript
NexThoughts Technologies
 
PPTX
Typescript: Beginner to Advanced
Talentica Software
 
PPTX
The advantage of developing with TypeScript
Corley S.r.l.
 
PPTX
Why do we need TypeScript?
Nitay Neeman
 
PPTX
All You Need to Know About Type Script
Folio3 Software
 
PDF
TYPESCRIPT.pdfgshshhsjajajsjsjjsjajajjajjj
sonidsxyz02
 
PPTX
Type script
Mallikarjuna G D
 
PPTX
TypeScript
Software Infrastructure
 
DOC
Typescript Basics
Manikandan [M M K]
 
PDF
One language to rule them all type script
Gil Fink
 
TypeScript: Angular's Secret Weapon
Laurent Duveau
 
TypeScript: Basic Features and Compilation Guide
Nascenia IT
 
Type script
Zunair Shoes
 
Typescript language extension of java script
michaelaaron25322
 
TypeScript.ppt LPU Notes Lecture PPT for 2024
manveersingh2k05
 
TypeScript Interview Questions PDF By ScholarHat
Scholarhat
 
Reasons to Use Typescript for Your Next Project Over Javascript.pdf
MobMaxime
 
Complete Notes on Angular 2 and TypeScript
EPAM Systems
 
Getting Started with the TypeScript Language
Gil Fink
 
typescript.pptx
ZeynepOtu
 
Introduction to TypeScript
NexThoughts Technologies
 
Typescript: Beginner to Advanced
Talentica Software
 
The advantage of developing with TypeScript
Corley S.r.l.
 
Why do we need TypeScript?
Nitay Neeman
 
All You Need to Know About Type Script
Folio3 Software
 
TYPESCRIPT.pdfgshshhsjajajsjsjjsjajajjajjj
sonidsxyz02
 
Type script
Mallikarjuna G D
 
Typescript Basics
Manikandan [M M K]
 
One language to rule them all type script
Gil Fink
 
Ad

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
Debugging an Angular App
Laurent Duveau
 
PDF
Introduction to Angular with TypeScript for .NET Developers
Laurent Duveau
 
PDF
Introduction to Angular 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
 
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
 
Debugging an Angular App
Laurent Duveau
 
Introduction to Angular with TypeScript for .NET Developers
Laurent Duveau
 
Introduction to Angular 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
 

Recently uploaded (20)

PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
Digital Circuits, important subject in CS
contactparinay1
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 

TypeScript: Angular's Secret Weapon