SlideShare a Scribd company logo
Introduction to TypeScript
Udayakumar Mathivanan
Cloud Solution Architect
Your Logo
AGENDA
Why TypeScript?
Language introduction / live-coding
TypeScript and Angular
Comparison with TS alternatives
Conclusion
Your Logo
WHAT'S WRONG WITH JAVASCRIPT?
Dynamic typing
Lack of modularity
Verbose patterns (IIFE)
In short: JavaScript development scales badly
Your Logo
WHAT'S GOOD ABOUT JAVASCRIPT?
It's everywhere
Huge amount of libraries
Flexible
Your Logo
WISHLIST
Scalable HTML5 clientside development
Modular development
Easily learnable for Java developers
Non-invasive (existing libs, browser support)
Long-term vision
Clean JS output (exit strategy)
Your Logo
TYPESCRIPT
In short: Lightweight productivity booster
Superset of JavaScript
Optionally typed
Compiles to ES3/ES5
No special runtime
1.0 in April 2014, future ES6 alignment
Your Logo
GETTING STARTED
$ npm install -g typescript
$ mv mycode.js mycode.ts
$ tsc mycode.ts
OPTIONAL TYPES
Type annotations
> var a = 123
> a.trim()
TypeError: undefined is
not a function
J
S
= 123> var a: string
> a.trim()
'number'Cannot convert
to 'string'.
TS
Type inference
Types dissapear at runtime
> var a = 123
> a.trim()
The property
not exist on
'trim' does
value of
type 'number'.
Your Logo
boolean number string type[]any void
Object void boolean integer
long
short
...
String
char
Type[]
OPTIONAL TYPES
Your Logo
OPTIONAL TYPES
Types are structural rather than nominal
TypeScript has function types:
var
find:
(elem: string, elems: string[]) => string =
function(elem, elems) {
..
}
Your Logo
INTERFACES
MyInterface {
signature
interface
// Call
(param:
member:
number): string
number
optionalMember?: number
myMethod(param: string): void
MyInterface = ...
}
var instance:
instance(1)
Your Logo
INTERFACES
Use them to describe data returned in REST calls
User) => {$.getJSON('user/123').then((user:
showProfile(user.details)
}
Your Logo
INTERFACES
TS interfaces are open-ended:
interface JQuery {
appendTo(..): ..
..
}
interface JQuery {
draggable(..): ..
..
}jquery.d.t
s
jquery.ui.d.t
s
OPTIONAL TYPES: ENUMS
enum Language { TypeScript, Java, JavaScript }
Language.TypeScriptvar lang =
var ts = Language[0]
ts === "TypeScript"
enum Language { TypeScript = 1, Java, JavaScript }
var ts = Language[1]
TYPESCRIPT CLASSES
Can implement interfaces
Inheritance
Instance methods/members
Static methods/members
Single constructor
Default/optional parameters
ES6 class syntax
similar
different
Your Logo
ARROW FUNCTIONS
Implicit return
No braces for single expression
Part of ES6
function(arg1) {
return arg1.toLowerCase();
}
(arg1) => arg1.toLowerCase();
Lexically-scoped this (no more 'var that = this')
Your Logo
string): void }
module StorageModule {
export interface Storage { store(content:
var privateKey = 'storageKey';
export class LocalStorage implements Storage {
store(content: string): void {
localStorage.setItem(privateKey, content);
}
}
export class DevNullStorage Storage {
store(content: string):
implements
void { }
}
= new StorageModule.LocalStorage();
}
var storage: StorageModule.Storage
storage.store('testing');
INTERNAL MODULES
Your Logo
string): void }
module StorageModule {
export interface Storage { store(content:
var privateKey = 'storageKey';
export class LocalStorage implements Storage {
store(content: string): void {
localStorage.setItem(privateKey, content);
}
}
export class DevNullStorage Storage {
store(content: string):
implements
void { }
}
= new StorageModule.LocalStorage();
}
var storage: StorageModule.Storage
storage.store('testing');
INTERNAL MODULES
Your Logo
INTERNAL MODULES
TS internal modules are open-ended:
module
export class
Webshop {
Cart
}
/// <reference
module Webshop
path="cart.ts" />
{
export class
}
{ .. }
cart.ts
Catalog { .. }
main.ts
Your Logo
INTERNAL MODULES
TS internal modules are open-ended:
module
export class
Webshop {
Cart
}
/// <reference
module Webshop
path="cart.ts" />
{
export class
}
{ .. }
cart.ts
Catalog { .. }
main.ts
Can be hierarchical:
module Webshop.Cart.Backend {
...
}
Combine modules:
$ tsc --out main.js main.ts
Your Logo
BUILDING TYPESCRIPT
$ tsc -watch main.ts
grunt-typescript
grunt-ts
gulp-type (incremental)
gulp-tsc
Your Logo
TOOLING
IntelliJ IDEA
WebStorm
plugin
Your Logo
WHO USES TYPESCRIPT?
(duh)
TypeScript
Copy JS code Into TS file Compile to JavaScript
• TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
• TypeScript is a language for application scale JavaScript development.
• Any browser. Any host. Any OS.
• Open Source.
~typescriptlang.org
JS JSTS
TypeScript Key Features
• Support standard JavaScript code with static typing
• Zero cost: Static types completely disappear at run-time
• Encapsulation though classes, modules and interfaces
• Constructors, properties and functions (public, private)
• Enums
• Lambda and generics support
• Intellisense and syntax checking
• IDE support
• Visual Studio
• Sublime Text, Vi, Emacs
• Eclipse, WebStorm
• Preview Pane – Web Essentials
Highlights
Tool Features TypeScript Code
• Type Annotation
• Any and Primitive Type
• Interface, Implementation
• Class, constructor
• Opt. Parameter, overloads
• Event handler
• Get accessor, private, static
• Arrow function, lambda
• Module
• Typed definitions
• And more…
• Type Inference
• Intellisense, statement comp.
• Compile on Save
• Preview Pane
• ECMAScript version
• Redirect JavaScript output
• Generate declaration files
TypeScript Versions
• TypeScript 1.3 for VS older (Web Essentials)
• TypeScript 1.3 for VS 2013 Update 2
• TypeScript 1.4 for VS 2013
• TypeScript 1.4 for VS 2015 CTP5
• TypeScript 2.0 (vNext)
Your Logo
CONCLUSION
TypeScript allows for gradual adoption
Internal modules
Classes/Interfaces
Some typing
External modules
Type defs
More typing
Generics
Type defs
-noImplicitAny
Resources
• http://www.typescriptlang.org
• http://www.typescriptlang.org/Content/TypeScript%20Languag
e%20Specification.pdf
• http://www.typescriptlang.org/Playground
• http://vswebessentials.com/download
• https://github.com/borisyankov/DefinitelyTyped
• https://github.com/Microsoft/TypeScript
Angular 2: Built on TypeScript
• http://blogs.msdn.com/b/typescript/archive/2015/03/05/angul
ar-2-0-built-on-typescript.aspx
• http://blogs.msdn.com/b/visualstudio/archive/2015/03/12/a-
preview-of-angular-2-and-typescript-in-visual-studio.aspx
Summary
• Open source language that compiles into JavaScript
• Code encapsulation
• Maintainable code
• Tooling support
Application scale JavaScript development is hard
TypeScript makes it easier

More Related Content

What's hot

Getting started with typescript
Getting started with typescriptGetting started with typescript
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?
FITC
 
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
Malla Reddy University
 
TypeScript Best Practices
TypeScript Best PracticesTypeScript Best Practices
TypeScript Best Practices
felixbillon
 
TypeScript
TypeScriptTypeScript
TypeScript
Saray Chak
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
André Pitombeira
 
TypeScript
TypeScriptTypeScript
TypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptxTypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptx
Albiorix Technology
 
TypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideTypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation Guide
Nascenia IT
 
Typescript in React: HOW & WHY?
Typescript in React: HOW & WHY?Typescript in React: HOW & WHY?
Typescript in React: HOW & WHY?
Saulius Skeirys
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
Rob Eisenberg
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
Nikolaus Graf
 
TypeScript
TypeScriptTypeScript
TypeScript
Fabian Vilers
 
Angular vs. React
Angular vs. ReactAngular vs. React
Angular vs. React
OPITZ CONSULTING Deutschland
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
Shailendra Chauhan
 
Reactjs
Reactjs Reactjs
Reactjs
Neha Sharma
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
Samundra khatri
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
WebStackAcademy
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
Christoffer Noring
 

What's hot (20)

Getting started with typescript
Getting started with typescriptGetting started with typescript
Getting started with typescript
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the pain
 
Why TypeScript?
Why TypeScript?Why TypeScript?
Why TypeScript?
 
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
 
TypeScript Best Practices
TypeScript Best PracticesTypeScript Best Practices
TypeScript Best Practices
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
TypeScript
TypeScriptTypeScript
TypeScript
 
TypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptxTypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptx
 
TypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideTypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation Guide
 
Typescript in React: HOW & WHY?
Typescript in React: HOW & WHY?Typescript in React: HOW & WHY?
Typescript in React: HOW & WHY?
 
The New JavaScript: ES6
The New JavaScript: ES6The New JavaScript: ES6
The New JavaScript: ES6
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Angular vs. React
Angular vs. ReactAngular vs. React
Angular vs. React
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Reactjs
Reactjs Reactjs
Reactjs
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
Angular - Chapter 3 - Components
Angular - Chapter 3 - ComponentsAngular - Chapter 3 - Components
Angular - Chapter 3 - Components
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 

Viewers also liked

React & Redux
React & ReduxReact & Redux
React & Redux
Federico Bond
 
WordPress REST API + React + TypeScript
WordPress REST API + React + TypeScriptWordPress REST API + React + TypeScript
WordPress REST API + React + TypeScript
Borek Bernard
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
Remo Jansen
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
Laurent Duveau
 
TypeScript
TypeScriptTypeScript
TypeScript
GetDev.NET
 
Александр Русаков - TypeScript 2 in action
Александр Русаков - TypeScript 2 in actionАлександр Русаков - TypeScript 2 in action
Александр Русаков - TypeScript 2 in action
MoscowJS
 
Typescript
TypescriptTypescript
Typescript
Nikhil Thomas
 
TypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack DevelopersTypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack Developers
Rutenis Turcinas
 
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
MoscowJS
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
Yakov Fain
 
TypeScript Seminar
TypeScript SeminarTypeScript Seminar
TypeScript Seminar
Haim Michael
 
Power Leveling your TypeScript
Power Leveling your TypeScriptPower Leveling your TypeScript
Power Leveling your TypeScript
Offirmo
 
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
TypeScript: Un lenguaje aburrido para programadores torpes y tristesTypeScript: Un lenguaje aburrido para programadores torpes y tristes
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
Micael Gallego
 
Typescript tips & tricks
Typescript tips & tricksTypescript tips & tricks
Typescript tips & tricks
Ori Calvo
 
Angular 2 - Typescript
Angular 2  - TypescriptAngular 2  - Typescript
Angular 2 - Typescript
Nathan Krasney
 
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
Ontico
 
Typescript + Graphql = <3
Typescript + Graphql = <3Typescript + Graphql = <3
Typescript + Graphql = <3
felixbillon
 

Viewers also liked (17)

React & Redux
React & ReduxReact & Redux
React & Redux
 
WordPress REST API + React + TypeScript
WordPress REST API + React + TypeScriptWordPress REST API + React + TypeScript
WordPress REST API + React + TypeScript
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Александр Русаков - TypeScript 2 in action
Александр Русаков - TypeScript 2 in actionАлександр Русаков - TypeScript 2 in action
Александр Русаков - TypeScript 2 in action
 
Typescript
TypescriptTypescript
Typescript
 
TypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack DevelopersTypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack Developers
 
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
 
TypeScript Seminar
TypeScript SeminarTypeScript Seminar
TypeScript Seminar
 
Power Leveling your TypeScript
Power Leveling your TypeScriptPower Leveling your TypeScript
Power Leveling your TypeScript
 
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
TypeScript: Un lenguaje aburrido para programadores torpes y tristesTypeScript: Un lenguaje aburrido para programadores torpes y tristes
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
 
Typescript tips & tricks
Typescript tips & tricksTypescript tips & tricks
Typescript tips & tricks
 
Angular 2 - Typescript
Angular 2  - TypescriptAngular 2  - Typescript
Angular 2 - Typescript
 
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
 
Typescript + Graphql = <3
Typescript + Graphql = <3Typescript + Graphql = <3
Typescript + Graphql = <3
 

Similar to Typescript in 30mins

Getting Started with the TypeScript Language
Getting Started with the TypeScript LanguageGetting Started with the TypeScript Language
Getting Started with the TypeScript Language
Gil Fink
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
Scala Italy
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
Alberto Paro
 
Modern java script features
Modern java script featuresModern java script features
Modern java script features
Kunal Kursija
 
Web technologies-course 07.pptx
Web technologies-course 07.pptxWeb technologies-course 07.pptx
Web technologies-course 07.pptx
Stefan Oprea
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
Laurent Duveau
 
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
GeeksLab Odessa
 
Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platformRuslan Shevchenko
 
End-to-End SPA Development using TypeScript
End-to-End SPA Development using TypeScriptEnd-to-End SPA Development using TypeScript
End-to-End SPA Development using TypeScript
Gil Fink
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
Alessandro Giorgetti
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Codemotion
 
Next-generation JavaScript - OpenSlava 2014
Next-generation JavaScript - OpenSlava 2014Next-generation JavaScript - OpenSlava 2014
Next-generation JavaScript - OpenSlava 2014
Oscar Renalias
 
End to-end apps with type script
End to-end apps with type scriptEnd to-end apps with type script
End to-end apps with type script
Gil Fink
 
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
Gil Fink
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
Ngoc Dao
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayLuka Zakrajšek
 
TypeScript
TypeScriptTypeScript
Scala's evolving ecosystem- Introduction to Scala.js
Scala's evolving ecosystem- Introduction to Scala.jsScala's evolving ecosystem- Introduction to Scala.js
Scala's evolving ecosystem- Introduction to Scala.js
Knoldus Inc.
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
WebStackAcademy
 
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
Gil Fink
 

Similar to Typescript in 30mins (20)

Getting Started with the TypeScript Language
Getting Started with the TypeScript LanguageGetting Started with the TypeScript Language
Getting Started with the TypeScript Language
 
Alberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.jsAlberto Paro - Hands on Scala.js
Alberto Paro - Hands on Scala.js
 
Scala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJSScala Italy 2015 - Hands On ScalaJS
Scala Italy 2015 - Hands On ScalaJS
 
Modern java script features
Modern java script featuresModern java script features
Modern java script features
 
Web technologies-course 07.pptx
Web technologies-course 07.pptxWeb technologies-course 07.pptx
Web technologies-course 07.pptx
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
 
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
JSLab.Руслан Шевченко."JavaScript как платформа компиляции"
 
Jslab rssh: JS as language platform
Jslab rssh:  JS as language platformJslab rssh:  JS as language platform
Jslab rssh: JS as language platform
 
End-to-End SPA Development using TypeScript
End-to-End SPA Development using TypeScriptEnd-to-End SPA Development using TypeScript
End-to-End SPA Development using TypeScript
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
 
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
Alberto Maria Angelo Paro - Isomorphic programming in Scala and WebDevelopmen...
 
Next-generation JavaScript - OpenSlava 2014
Next-generation JavaScript - OpenSlava 2014Next-generation JavaScript - OpenSlava 2014
Next-generation JavaScript - OpenSlava 2014
 
End to-end apps with type script
End to-end apps with type scriptEnd to-end apps with type script
End to-end apps with type script
 
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
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and Play
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Scala's evolving ecosystem- Introduction to Scala.js
Scala's evolving ecosystem- Introduction to Scala.jsScala's evolving ecosystem- Introduction to Scala.js
Scala's evolving ecosystem- Introduction to Scala.js
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
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
 

More from Udaya Kumar

Knockout JS Development - a Quick Understanding
Knockout JS Development - a Quick UnderstandingKnockout JS Development - a Quick Understanding
Knockout JS Development - a Quick Understanding
Udaya Kumar
 
AzureML TechTalk
AzureML TechTalkAzureML TechTalk
AzureML TechTalk
Udaya Kumar
 
Innovations and Innovators Prepared by Sharika Shivani U.J
Innovations and Innovators   Prepared by Sharika Shivani U.JInnovations and Innovators   Prepared by Sharika Shivani U.J
Innovations and Innovators Prepared by Sharika Shivani U.J
Udaya Kumar
 
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar Mathivanan
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar MathivananHtml5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar Mathivanan
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar MathivananUdaya Kumar
 
KnockOutjs from Scratch
KnockOutjs from ScratchKnockOutjs from Scratch
KnockOutjs from ScratchUdaya Kumar
 
BDOTNET AngularJs Directives - Uday
BDOTNET AngularJs Directives - UdayBDOTNET AngularJs Directives - Uday
BDOTNET AngularJs Directives - UdayUdaya Kumar
 
Social Reformers Of India Prepared by Sharika Shivani U.J
Social Reformers Of India   Prepared by Sharika Shivani U.JSocial Reformers Of India   Prepared by Sharika Shivani U.J
Social Reformers Of India Prepared by Sharika Shivani U.J
Udaya Kumar
 
Html5 Exploring -- by Udayakumar Mathivanan
Html5 Exploring -- by Udayakumar MathivananHtml5 Exploring -- by Udayakumar Mathivanan
Html5 Exploring -- by Udayakumar Mathivanan
Udaya Kumar
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 days
Udaya Kumar
 

More from Udaya Kumar (9)

Knockout JS Development - a Quick Understanding
Knockout JS Development - a Quick UnderstandingKnockout JS Development - a Quick Understanding
Knockout JS Development - a Quick Understanding
 
AzureML TechTalk
AzureML TechTalkAzureML TechTalk
AzureML TechTalk
 
Innovations and Innovators Prepared by Sharika Shivani U.J
Innovations and Innovators   Prepared by Sharika Shivani U.JInnovations and Innovators   Prepared by Sharika Shivani U.J
Innovations and Innovators Prepared by Sharika Shivani U.J
 
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar Mathivanan
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar MathivananHtml5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar Mathivanan
Html5-Exploring-Training Deck - OSMOSIS 10Oct - By Udayakumar Mathivanan
 
KnockOutjs from Scratch
KnockOutjs from ScratchKnockOutjs from Scratch
KnockOutjs from Scratch
 
BDOTNET AngularJs Directives - Uday
BDOTNET AngularJs Directives - UdayBDOTNET AngularJs Directives - Uday
BDOTNET AngularJs Directives - Uday
 
Social Reformers Of India Prepared by Sharika Shivani U.J
Social Reformers Of India   Prepared by Sharika Shivani U.JSocial Reformers Of India   Prepared by Sharika Shivani U.J
Social Reformers Of India Prepared by Sharika Shivani U.J
 
Html5 Exploring -- by Udayakumar Mathivanan
Html5 Exploring -- by Udayakumar MathivananHtml5 Exploring -- by Udayakumar Mathivanan
Html5 Exploring -- by Udayakumar Mathivanan
 
WPF For Beginners - Learn in 3 days
WPF For Beginners  - Learn in 3 daysWPF For Beginners  - Learn in 3 days
WPF For Beginners - Learn in 3 days
 

Recently uploaded

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 

Recently uploaded (20)

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 

Typescript in 30mins

  • 1. Introduction to TypeScript Udayakumar Mathivanan Cloud Solution Architect
  • 2. Your Logo AGENDA Why TypeScript? Language introduction / live-coding TypeScript and Angular Comparison with TS alternatives Conclusion
  • 3. Your Logo WHAT'S WRONG WITH JAVASCRIPT? Dynamic typing Lack of modularity Verbose patterns (IIFE) In short: JavaScript development scales badly
  • 4. Your Logo WHAT'S GOOD ABOUT JAVASCRIPT? It's everywhere Huge amount of libraries Flexible
  • 5. Your Logo WISHLIST Scalable HTML5 clientside development Modular development Easily learnable for Java developers Non-invasive (existing libs, browser support) Long-term vision Clean JS output (exit strategy)
  • 6. Your Logo TYPESCRIPT In short: Lightweight productivity booster Superset of JavaScript Optionally typed Compiles to ES3/ES5 No special runtime 1.0 in April 2014, future ES6 alignment
  • 7. Your Logo GETTING STARTED $ npm install -g typescript $ mv mycode.js mycode.ts $ tsc mycode.ts
  • 8. OPTIONAL TYPES Type annotations > var a = 123 > a.trim() TypeError: undefined is not a function J S = 123> var a: string > a.trim() 'number'Cannot convert to 'string'. TS Type inference Types dissapear at runtime > var a = 123 > a.trim() The property not exist on 'trim' does value of type 'number'.
  • 9. Your Logo boolean number string type[]any void Object void boolean integer long short ... String char Type[] OPTIONAL TYPES
  • 10. Your Logo OPTIONAL TYPES Types are structural rather than nominal TypeScript has function types: var find: (elem: string, elems: string[]) => string = function(elem, elems) { .. }
  • 11. Your Logo INTERFACES MyInterface { signature interface // Call (param: member: number): string number optionalMember?: number myMethod(param: string): void MyInterface = ... } var instance: instance(1)
  • 12. Your Logo INTERFACES Use them to describe data returned in REST calls User) => {$.getJSON('user/123').then((user: showProfile(user.details) }
  • 13. Your Logo INTERFACES TS interfaces are open-ended: interface JQuery { appendTo(..): .. .. } interface JQuery { draggable(..): .. .. }jquery.d.t s jquery.ui.d.t s
  • 14. OPTIONAL TYPES: ENUMS enum Language { TypeScript, Java, JavaScript } Language.TypeScriptvar lang = var ts = Language[0] ts === "TypeScript" enum Language { TypeScript = 1, Java, JavaScript } var ts = Language[1]
  • 15. TYPESCRIPT CLASSES Can implement interfaces Inheritance Instance methods/members Static methods/members Single constructor Default/optional parameters ES6 class syntax similar different
  • 16. Your Logo ARROW FUNCTIONS Implicit return No braces for single expression Part of ES6 function(arg1) { return arg1.toLowerCase(); } (arg1) => arg1.toLowerCase(); Lexically-scoped this (no more 'var that = this')
  • 17. Your Logo string): void } module StorageModule { export interface Storage { store(content: var privateKey = 'storageKey'; export class LocalStorage implements Storage { store(content: string): void { localStorage.setItem(privateKey, content); } } export class DevNullStorage Storage { store(content: string): implements void { } } = new StorageModule.LocalStorage(); } var storage: StorageModule.Storage storage.store('testing'); INTERNAL MODULES
  • 18. Your Logo string): void } module StorageModule { export interface Storage { store(content: var privateKey = 'storageKey'; export class LocalStorage implements Storage { store(content: string): void { localStorage.setItem(privateKey, content); } } export class DevNullStorage Storage { store(content: string): implements void { } } = new StorageModule.LocalStorage(); } var storage: StorageModule.Storage storage.store('testing'); INTERNAL MODULES
  • 19. Your Logo INTERNAL MODULES TS internal modules are open-ended: module export class Webshop { Cart } /// <reference module Webshop path="cart.ts" /> { export class } { .. } cart.ts Catalog { .. } main.ts
  • 20. Your Logo INTERNAL MODULES TS internal modules are open-ended: module export class Webshop { Cart } /// <reference module Webshop path="cart.ts" /> { export class } { .. } cart.ts Catalog { .. } main.ts Can be hierarchical: module Webshop.Cart.Backend { ... } Combine modules: $ tsc --out main.js main.ts
  • 21. Your Logo BUILDING TYPESCRIPT $ tsc -watch main.ts grunt-typescript grunt-ts gulp-type (incremental) gulp-tsc
  • 23. Your Logo WHO USES TYPESCRIPT? (duh)
  • 24. TypeScript Copy JS code Into TS file Compile to JavaScript • TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. • TypeScript is a language for application scale JavaScript development. • Any browser. Any host. Any OS. • Open Source. ~typescriptlang.org JS JSTS
  • 25. TypeScript Key Features • Support standard JavaScript code with static typing • Zero cost: Static types completely disappear at run-time • Encapsulation though classes, modules and interfaces • Constructors, properties and functions (public, private) • Enums • Lambda and generics support • Intellisense and syntax checking • IDE support • Visual Studio • Sublime Text, Vi, Emacs • Eclipse, WebStorm • Preview Pane – Web Essentials
  • 26. Highlights Tool Features TypeScript Code • Type Annotation • Any and Primitive Type • Interface, Implementation • Class, constructor • Opt. Parameter, overloads • Event handler • Get accessor, private, static • Arrow function, lambda • Module • Typed definitions • And more… • Type Inference • Intellisense, statement comp. • Compile on Save • Preview Pane • ECMAScript version • Redirect JavaScript output • Generate declaration files
  • 27. TypeScript Versions • TypeScript 1.3 for VS older (Web Essentials) • TypeScript 1.3 for VS 2013 Update 2 • TypeScript 1.4 for VS 2013 • TypeScript 1.4 for VS 2015 CTP5 • TypeScript 2.0 (vNext)
  • 28. Your Logo CONCLUSION TypeScript allows for gradual adoption Internal modules Classes/Interfaces Some typing External modules Type defs More typing Generics Type defs -noImplicitAny
  • 29. Resources • http://www.typescriptlang.org • http://www.typescriptlang.org/Content/TypeScript%20Languag e%20Specification.pdf • http://www.typescriptlang.org/Playground • http://vswebessentials.com/download • https://github.com/borisyankov/DefinitelyTyped • https://github.com/Microsoft/TypeScript
  • 30. Angular 2: Built on TypeScript • http://blogs.msdn.com/b/typescript/archive/2015/03/05/angul ar-2-0-built-on-typescript.aspx • http://blogs.msdn.com/b/visualstudio/archive/2015/03/12/a- preview-of-angular-2-and-typescript-in-visual-studio.aspx
  • 31. Summary • Open source language that compiles into JavaScript • Code encapsulation • Maintainable code • Tooling support Application scale JavaScript development is hard TypeScript makes it easier