SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
One language to rule them all:
TypeScript
Gil Fink
CEO and senior consultant, sparXys
About Me
• sparXys CEO and senior consultant
• Microsoft MVP in the last 8 years
• Pro Single Page Application Development (Apress) co-author
• 4 Microsoft Official Courses (MOCs) co-author
• GDG Rishon and AngularUP co-organizer
Agenda
• The why
• TypeScript syntax and language features
• Building a simple end-to-end app with TypeScript
• Summary
Wait!
JavaScript?
Are you nuts?
"JavaScript is the assembly
language of the Web"
Erik Meijer
“You can write large
programs in JavaScript. You
just can’t maintain them”
Anders Hejlsberg
Let’s Be Serious
• JavaScript is really a powerful language:
o Functional
o Dynamic
o Can run everywhere
• Huge community
• Big eco-system
• Tools – IDEs, debuggers, test tools and etc.
The Alternatives
• We have several alternatives:
• Hard core vanilla JavaScript development
• JavaScript transpilers
• CoffeeScript – http://coffeescript.org
• Dart – http://dartlang.org
• Clojurescript - https://github.com/clojure/clojurescript
• Script# - http://scriptsharp.com/
What is TypeScript?
“TypeScript is a typed superset of JavaScript that compiles to
plain JavaScript” ~typescriptlang.org
Hello TypeScript
Demo
TypeScript is Very
Flexible
Any Browser Any Host
Any OS Tool Support
Some TypeScript Key
Features
Support
standard
JavaScript
code with
static typing
Encapsulation
through classes
and modules
Support for
constructors,
properties and
functions
Interfaces and
enums
support
Lambda and
generics
support
Intellisense
and syntax
checking
• Modules
• Classes
• Arrow functions
• Default parameters
• Destructuring
• Spread and rest
• Let and const
• for...of
• Object literal
methods
• Shorthand
properties
• Computed
properties
• Octal / binary
literals
• Symbols
• Template strings
• Async/Await
Features from the near Future of
the Web (ES2015/6/7), Today
Choose your
compilation scenario.
It is up to you!
From TypeScript to
JavaScript
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
greet() {
return “Hi," + this.greeting;
}
}
TypeScript Code JavaScript Code
TypeScript
Compiler
var Greeter = (function () {
function Greeter(message) {
this.greeting = message;
}
Greeter.prototype.greet =
function () {
return “Hi," + this.greeting;
};
return Greeter;
})();
tsc.js
How Good is TypeScript’s
Output?
tsconfig.json
• Enables to configure the compiler options:
o Target language (ES3, ES5, ES2015)
o Module system (AMD, ES2015, CommonJS and etc.)
o Source map generation
o Remove comments when compiling
o And more
tsconfig.json
Demo
Some Important Side
Notes
• All JavaScript code is TypeScript code
o Simply copy and paste
• All JavaScript libraries work with TypeScript
o You will need a declaration file to work with the library
@Types
Demo
TypeScript Type
Annotations
• You can add type annotations to variables and
functions
var str: string = ‘hello’; // str is annotated as string
function foo(name: string) : string { // parameter and function annotated
return ‘hello’ + name;
}
TypeScript Types
Type Annotations
Demo
Classes and Interfaces
• You can define classes (same as in ES2015)
• You can define interfaces
o And implement them later
interface IGreeter {
greet(): void;
}
class Greeter implements IGreeter{
greeting: string;
greet() {
console.log(this.greeting);
}
}
var Greeter = (function () {
function Greeter() {
}
Greeter.prototype.greet = function () {
console.log(this.greeting);
};
return Greeter;
})();
Modules
• Uses ES2015 modules syntax
export interface IGreeter {
greet(): void;
}
export class Greeter implements
IGreeter {
greeting: string;
greet() {
console.log(this.greeting);
}
}
var Greeter = (function () {
function Greeter() {
}
Greeter.prototype.greet = function ()
{
console.log(this.greeting);
};
return Greeter;
}());
exports.Greeter = Greeter;
Classes, Modules and
Interfaces
Demo
Building a Simple
End-to-End App with
TypeScript
Demo
TypeScript Versions
• TypeScript 1.0
• TypeScript 2.0
• Current version: TypeScript 2.3.2
What’s New in TypeScript
2?
• Generators and Iteration for ES5/ES3
• Type-checking for JavaScript files
• Null- and undefined-aware types
• ES2017 Spread and Rest
• Improved any inference
• Tagged union types
• And a lot more
Summary
• Open source language that compiles into
JavaScript
• Key features:
• Code encapsulation
• Maintainable code
• Tooling support
• Learn TypeScript today!
Resources
• TypeScript – http://www.typescriptlang.org
• TypeScript Source Code -
https://github.com/Microsoft/TypeScript
• My Website – http://www.gilfink.net
• Follow me on Twitter – @gilfink
Thank You!
Questions?

Contenu connexe

Tendances

Tendances (20)

Typescript Fundamentals
Typescript FundamentalsTypescript Fundamentals
Typescript Fundamentals
 
Typescript language
Typescript languageTypescript language
Typescript language
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
 
TypeScript - An Introduction
TypeScript - An IntroductionTypeScript - An Introduction
TypeScript - An Introduction
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
Introducing type script
Introducing type scriptIntroducing type script
Introducing type script
 
Why do we need TypeScript?
Why do we need TypeScript?Why do we need TypeScript?
Why do we need TypeScript?
 
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
 
Introduction to Angular for .NET Developers
Introduction to Angular for .NET DevelopersIntroduction to Angular for .NET Developers
Introduction to Angular for .NET Developers
 
Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
 
TypeScript 101 - Studio Session - Accenture Liquid Studio
TypeScript 101 - Studio Session - Accenture Liquid StudioTypeScript 101 - Studio Session - Accenture Liquid Studio
TypeScript 101 - Studio Session - Accenture Liquid Studio
 
Introduction about type script
Introduction about type scriptIntroduction about type script
Introduction about type script
 
Introducing TypeScript
Introducing TypeScriptIntroducing TypeScript
Introducing 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 and Angular workshop
TypeScript and Angular workshopTypeScript and Angular workshop
TypeScript and Angular workshop
 
Typescript - MentorMate Academy
Typescript - MentorMate AcademyTypescript - MentorMate Academy
Typescript - MentorMate Academy
 
Typescript for the programmers who like javascript
Typescript for the programmers who like javascriptTypescript for the programmers who like javascript
Typescript for the programmers who like javascript
 
Introduction to TypeScript by Winston Levi
Introduction to TypeScript by Winston LeviIntroduction to TypeScript by Winston Levi
Introduction to TypeScript by Winston Levi
 
Globant development week / Web workers
Globant development week / Web workersGlobant development week / Web workers
Globant development week / Web workers
 
HelsinkiJS - Clojurescript for Javascript Developers
HelsinkiJS - Clojurescript for Javascript DevelopersHelsinkiJS - Clojurescript for Javascript Developers
HelsinkiJS - Clojurescript for Javascript Developers
 

Similaire à One language to rule them all type script

Similaire à One language to rule them all type script (20)

Type script
Type scriptType script
Type script
 
Mini-Training: TypeScript
Mini-Training: TypeScriptMini-Training: TypeScript
Mini-Training: TypeScript
 
Typescript: JS code just got better!
Typescript: JS code just got better!Typescript: JS code just got better!
Typescript: JS code just got better!
 
One language to rule them all type script
One language to rule them all type scriptOne language to rule them all type script
One language to rule them all type script
 
Building End to-End Web Apps Using TypeScript
Building End to-End Web Apps Using TypeScriptBuilding End to-End Web Apps Using TypeScript
Building End to-End Web Apps Using TypeScript
 
Angular2
Angular2Angular2
Angular2
 
The advantage of developing with TypeScript
The advantage of developing with TypeScript The advantage of developing with TypeScript
The advantage of developing with TypeScript
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
 
Type script
Type scriptType script
Type script
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Benefits of Typescript.pptx
Benefits of Typescript.pptxBenefits of Typescript.pptx
Benefits of Typescript.pptx
 
Building End-to-End Apps Using Typescript
Building End-to-End Apps Using TypescriptBuilding End-to-End Apps Using Typescript
Building End-to-End Apps Using Typescript
 
TypeScript-SPS-melb.pptx
TypeScript-SPS-melb.pptxTypeScript-SPS-melb.pptx
TypeScript-SPS-melb.pptx
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
Crystal internals (part 1)
Crystal internals (part 1)Crystal internals (part 1)
Crystal internals (part 1)
 
Intro to TypeScript, HTML5DevConf Oct 2013
Intro to TypeScript, HTML5DevConf Oct 2013Intro to TypeScript, HTML5DevConf Oct 2013
Intro to TypeScript, HTML5DevConf Oct 2013
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
The Ring programming language version 1.4 book - Part 2 of 30
The Ring programming language version 1.4 book - Part 2 of 30The Ring programming language version 1.4 book - Part 2 of 30
The Ring programming language version 1.4 book - Part 2 of 30
 
TypeScript for Alfresco and CMIS - Alfresco DevCon 2012 San Jose
TypeScript for Alfresco and CMIS - Alfresco DevCon 2012 San JoseTypeScript for Alfresco and CMIS - Alfresco DevCon 2012 San Jose
TypeScript for Alfresco and CMIS - Alfresco DevCon 2012 San Jose
 

Plus de Gil Fink

Plus de Gil Fink (20)

Becoming a Tech Speaker
Becoming a Tech SpeakerBecoming a Tech Speaker
Becoming a Tech Speaker
 
Web animation on steroids web animation api
Web animation on steroids web animation api Web animation on steroids web animation api
Web animation on steroids web animation api
 
The Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has ArrivedThe Time for Vanilla Web Components has Arrived
The Time for Vanilla Web Components has Arrived
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
Stencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has ArrivedStencil: The Time for Vanilla Web Components has Arrived
Stencil: The Time for Vanilla Web Components has Arrived
 
Stencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrivedStencil the time for vanilla web components has arrived
Stencil the time for vanilla web components has arrived
 
Being a tech speaker
Being a tech speakerBeing a tech speaker
Being a tech speaker
 
Working with Data in Service Workers
Working with Data in Service WorkersWorking with Data in Service Workers
Working with Data in Service Workers
 
Demystifying Angular Animations
Demystifying Angular AnimationsDemystifying Angular Animations
Demystifying Angular Animations
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angular
 
Redux data flow with angular
Redux data flow with angularRedux data flow with angular
Redux data flow with angular
 
Who's afraid of front end databases?
Who's afraid of front end databases?Who's afraid of front end databases?
Who's afraid of front end databases?
 
Web component driven development
Web component driven developmentWeb component driven development
Web component driven development
 
Web components
Web componentsWeb components
Web components
 
Redux data flow with angular 2
Redux data flow with angular 2Redux data flow with angular 2
Redux data flow with angular 2
 
Biological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJSBiological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJS
 
Who's afraid of front end databases
Who's afraid of front end databasesWho's afraid of front end databases
Who's afraid of front end databases
 
Biological modeling, powered by angular js
Biological modeling, powered by angular jsBiological modeling, powered by angular js
Biological modeling, powered by angular js
 
Web components the future is here
Web components   the future is hereWeb components   the future is here
Web components the future is here
 

Dernier

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

One language to rule them all type script

  • 1. One language to rule them all: TypeScript Gil Fink CEO and senior consultant, sparXys
  • 2. About Me • sparXys CEO and senior consultant • Microsoft MVP in the last 8 years • Pro Single Page Application Development (Apress) co-author • 4 Microsoft Official Courses (MOCs) co-author • GDG Rishon and AngularUP co-organizer
  • 3. Agenda • The why • TypeScript syntax and language features • Building a simple end-to-end app with TypeScript • Summary
  • 5. "JavaScript is the assembly language of the Web" Erik Meijer
  • 6. “You can write large programs in JavaScript. You just can’t maintain them” Anders Hejlsberg
  • 7. Let’s Be Serious • JavaScript is really a powerful language: o Functional o Dynamic o Can run everywhere • Huge community • Big eco-system • Tools – IDEs, debuggers, test tools and etc.
  • 8. The Alternatives • We have several alternatives: • Hard core vanilla JavaScript development • JavaScript transpilers • CoffeeScript – http://coffeescript.org • Dart – http://dartlang.org • Clojurescript - https://github.com/clojure/clojurescript • Script# - http://scriptsharp.com/
  • 9. What is TypeScript? “TypeScript is a typed superset of JavaScript that compiles to plain JavaScript” ~typescriptlang.org
  • 11. TypeScript is Very Flexible Any Browser Any Host Any OS Tool Support
  • 12. Some TypeScript Key Features Support standard JavaScript code with static typing Encapsulation through classes and modules Support for constructors, properties and functions Interfaces and enums support Lambda and generics support Intellisense and syntax checking
  • 13. • Modules • Classes • Arrow functions • Default parameters • Destructuring • Spread and rest • Let and const • for...of • Object literal methods • Shorthand properties • Computed properties • Octal / binary literals • Symbols • Template strings • Async/Await Features from the near Future of the Web (ES2015/6/7), Today Choose your compilation scenario. It is up to you!
  • 14. From TypeScript to JavaScript class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { return “Hi," + this.greeting; } } TypeScript Code JavaScript Code TypeScript Compiler var Greeter = (function () { function Greeter(message) { this.greeting = message; } Greeter.prototype.greet = function () { return “Hi," + this.greeting; }; return Greeter; })(); tsc.js
  • 15. How Good is TypeScript’s Output?
  • 16. tsconfig.json • Enables to configure the compiler options: o Target language (ES3, ES5, ES2015) o Module system (AMD, ES2015, CommonJS and etc.) o Source map generation o Remove comments when compiling o And more
  • 18. Some Important Side Notes • All JavaScript code is TypeScript code o Simply copy and paste • All JavaScript libraries work with TypeScript o You will need a declaration file to work with the library
  • 20. TypeScript Type Annotations • You can add type annotations to variables and functions var str: string = ‘hello’; // str is annotated as string function foo(name: string) : string { // parameter and function annotated return ‘hello’ + name; }
  • 23. Classes and Interfaces • You can define classes (same as in ES2015) • You can define interfaces o And implement them later interface IGreeter { greet(): void; } class Greeter implements IGreeter{ greeting: string; greet() { console.log(this.greeting); } } var Greeter = (function () { function Greeter() { } Greeter.prototype.greet = function () { console.log(this.greeting); }; return Greeter; })();
  • 24. Modules • Uses ES2015 modules syntax export interface IGreeter { greet(): void; } export class Greeter implements IGreeter { greeting: string; greet() { console.log(this.greeting); } } var Greeter = (function () { function Greeter() { } Greeter.prototype.greet = function () { console.log(this.greeting); }; return Greeter; }()); exports.Greeter = Greeter;
  • 26. Building a Simple End-to-End App with TypeScript Demo
  • 27. TypeScript Versions • TypeScript 1.0 • TypeScript 2.0 • Current version: TypeScript 2.3.2
  • 28. What’s New in TypeScript 2? • Generators and Iteration for ES5/ES3 • Type-checking for JavaScript files • Null- and undefined-aware types • ES2017 Spread and Rest • Improved any inference • Tagged union types • And a lot more
  • 29. Summary • Open source language that compiles into JavaScript • Key features: • Code encapsulation • Maintainable code • Tooling support • Learn TypeScript today!
  • 30. Resources • TypeScript – http://www.typescriptlang.org • TypeScript Source Code - https://github.com/Microsoft/TypeScript • My Website – http://www.gilfink.net • Follow me on Twitter – @gilfink