SlideShare a Scribd company logo
© 2016, Right IT Services. All rights reserved
TypeScript
Friday, 02 December 2016
2
What’s TypeScript?
TypeScript
First appered 2012
Free and OpenSource project by Microsoft
Created by the father of C# Anders Hejlsberg
Typed superset of JavaScript
A new language that compiles to plain JavaScript
ES3 - ES5, ES6
2009
3
Friends - Who’s Using TypeScript?
TypeScript
4
Why TypeScript?
TypeScript
JavaScript
SUCKS!
5
Why TypeScript?
JS is interpreted, not compiled
There are no design-time intellisense or compile-time assistance to help you point out errors
A function is your contract with your caller
Function with parameters are more like guidelines
Global Scope
Why is the method called includes and not contains in Array?
MooTools adds this method to Array.prototype.
Scope
TypeScript
function func(anyvar) {
console.log(arguments.length);
return anyvar+ 1;
}
func();
func(“Change to TypeScript");
func("Change to", "TypeScript");
func(function(){});
f(1,2,3,4,5); //5
var foo = 1;
function test1() { foo = 2; console.log(foo); };
test1(); console.log(foo);
var foo = 3;
function test2() { var foo = 4; console.log(foo); };
test2(); console.log(foo);
6
Why TypeScript?
Object extension
Object inheritance is possible, but too messy
Some pitfalls
TypeScript
var a = "2";
var b = "2";
var c = a * b; //4
var a = "a";
var b = "b";
var c = a * b; //NaN
console.log('4' - 4);
console.log('4' + 4);
//0
//44
undefined == undefined //true
null == undefined //true
null === undefined //false
0 == undefined //false
”” == undefined //false
false == undefined //false
false == 0 //true
false == ”” //true
void 0
var x = { a : 1, b : 2 }
x.c = 3;
console.log(x[“a”] + x.b + x.c);
7
Features of TypeScript
Namespaces & Modules
Nomenclature has changed
Align with ECMAScript 2015
TypeScript
namespace Animal {
export namespace Domestic {
export function move(distance: number): boolean {
}
}
}
var moved = Animal.Domestic.move(100);
8
Features of TypeScript
Interfaces
TypeScript
enum Direction{
Right = 0,
Left = 1
}
interface Animal {
name: string;
age: number;
domestic: boolean;
}
interface Animal {
move(distance: number, direction: Direction);
}
export class Cat implements Animal{
...
}
9
TypeScript Features
Abstract & Classes
TypeScript
abstract class Animal {
abstract getName(): string;
}
class Cat extends Animal {
constructor() {
super();
}
public getName(): string {
return "";
}
}
class Dog extends Animal {
constructor() {
super();
}
getName(): string {
return "";
}
}
class Kennel<T extends Animal> {
getName<T extends Animal>(animal: T) : string {
return animal.getName();
}
}
var cat = new Cat();
var dog: Dog = new Dog();
var kennel = new Kennel();
var animal1 = kennel.getName(cat);
var animal2 = kennel.getName(dog);
10
TypeScript Features
Variable Scoping
TypeScript
for (var i = 0; i < this.length; i++) {
…
}
for (var i = 0; i < this.length; i++) { //Error
…
}
if(this.length > 0) {
let self = this[1]; //scoped only to if conditional
}
11
TypeScript Features
Declaration Files
.d.ts files containing declarative statements to describe TypeScript modules, classes, objects, etc.
Definition files for common JavaScript libraries makes them very easy to work with, and provides strong type checking
TypeScript
12
TypeScript Declaration Files
Variable Scoping
TypeScript
for (var i = 0; i < this.length; i++) {
…
}
for (var i = 0; i < this.length; i++) { //Error
…
}
if(this.length > 0) {
let self = this[1]; //scoped only to if conditional
}
13
Problems TypeScript Solves
Type safety
All the features are optionals
We can not use types
All valid JavaScript is valid TypeScript
Modules
TypeScript
module outer {
var str = "hello world";
}
var outer;
(function (outer) {
var str = "hello world";
})(outer || (outer = {}));
14
Problems TypeScript Solves
Checks Types
Less Runtime Bugs
Less Unit Tests
assert.isString
assert.isNumber
TypeScript
15
Problems TypeScript Doesn’t Solve
Mistakes
Logical mistakes
Lack of knowledge
Still need to understand JS
TS without knowing JS == disaster
what output will TS provide?
Won't make it faster
Won't make you code faster
Won't make app run faster
The any type
Stands for NO TYPE
Very easy and tempting to use
Will spoil your app if used in big amounts
Debug
browsers don't execute TS
source and output: different
TypeScript
16
Conclusion
TypeScript
WHEN YOU HAVE TO DO IT, DO IT RIGHT
© 2016, Right IT Services. All rights reserved Rua Odette Saint Maurice Lote 3B | Edifício L | Escritório A | Piso -1 | 1700-097 Lisboa | Portugal | +351 218 232 261
Pedro Azevedo – Technical Lead Dynamics CRM
Environment Microsoft Dynamics CRM
Friday, 02 December 2016
TypeScript

More Related Content

PPTX
Rits Brown Bag - Salesforce Lightning
PPTX
Introduction to lightning components
PPTX
Salesforce Lightning Design System
PPTX
Mule Integration with Atlassian JIRA
PPTX
Migrating to Salesforce Lightning - A Personal Experience Presented to EA For...
PDF
synebo talk #1 Salesforce lightning
PPTX
Aura Framework and Lightning (Nikolay Zenko and Alexey Filippov)
PPTX
Internet of things the salesforce lego machine cloud
Rits Brown Bag - Salesforce Lightning
Introduction to lightning components
Salesforce Lightning Design System
Mule Integration with Atlassian JIRA
Migrating to Salesforce Lightning - A Personal Experience Presented to EA For...
synebo talk #1 Salesforce lightning
Aura Framework and Lightning (Nikolay Zenko and Alexey Filippov)
Internet of things the salesforce lego machine cloud

What's hot (19)

PPTX
Lightning strikes twice- SEDreamin
PPTX
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
PPTX
Salesforce Coding techniques that keep your admins happy (DF13)
PDF
Salesforce lightning design system
PDF
PDF
How to tdd your mvp
PPTX
Force.com Friday - Intro to Visualforce
PPTX
Discover Salesforce Lightning 1
ODP
Salesforce Super Slider Lightning Component ppt
PPTX
2014 SharePoint Saturday Melbourne Apps or not to Apps
PDF
Forge UI: A New Way to Customize the Atlassian User Experience
PPTX
Lighnting component development
PPTX
Novidades Do Asp.Net 4 E Do Visual Studio 2010
PPTX
Lightning Components Workshop v2
DOCX
How DotNet, SharePoint, and Azure helps to build a Custom Web Application wi...
PDF
DF2UFL 2012: Developer's Den - What's New and What's on the Horizon
PPTX
Go Faster with Lightning - Overview
PDF
Updates on the Data Center Apps Program
PDF
Powerapps & Flow
Lightning strikes twice- SEDreamin
Hands-On Workshop: Introduction to Coding for on Force.com for Admins and Non...
Salesforce Coding techniques that keep your admins happy (DF13)
Salesforce lightning design system
How to tdd your mvp
Force.com Friday - Intro to Visualforce
Discover Salesforce Lightning 1
Salesforce Super Slider Lightning Component ppt
2014 SharePoint Saturday Melbourne Apps or not to Apps
Forge UI: A New Way to Customize the Atlassian User Experience
Lighnting component development
Novidades Do Asp.Net 4 E Do Visual Studio 2010
Lightning Components Workshop v2
How DotNet, SharePoint, and Azure helps to build a Custom Web Application wi...
DF2UFL 2012: Developer's Den - What's New and What's on the Horizon
Go Faster with Lightning - Overview
Updates on the Data Center Apps Program
Powerapps & Flow
Ad

Viewers also liked (20)

PPTX
Rits Brown Bag - Office 365
PPTX
Rits Brown Bag - Extending and Integrating in Microsoft Dynamics CRM
PPTX
Rits Brown Bag - PHP & PHPMyAdmin
PPT
single page application
PPTX
Angular 2 with TypeScript
PDF
The Tale of 2 CLIs - Ember-cli and Angular-cli
PDF
Single-Page Web Application Architecture
PPTX
Angular 2 + TypeScript = true. Let's Play!
PDF
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
PPTX
Angular 2 with TypeScript
PDF
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
PDF
Single page application
PPTX
Single page application
PPTX
Angular 1.x vs 2 - In code level
PDF
Getting started with Angular CLI
PPTX
02 Node introduction
PDF
Getting Started with the Angular 2 CLI
PPTX
Node js for beginners
PPTX
Node js introduction
PPTX
An afternoon with angular 2
Rits Brown Bag - Office 365
Rits Brown Bag - Extending and Integrating in Microsoft Dynamics CRM
Rits Brown Bag - PHP & PHPMyAdmin
single page application
Angular 2 with TypeScript
The Tale of 2 CLIs - Ember-cli and Angular-cli
Single-Page Web Application Architecture
Angular 2 + TypeScript = true. Let's Play!
Using Angular-CLI to Deploy an Angular 2 App Using Firebase in 30 Minutes
Angular 2 with TypeScript
Creating an Angular 2 Angular CLI app in 15 Minutes Using MaterializeCSS & Fi...
Single page application
Single page application
Angular 1.x vs 2 - In code level
Getting started with Angular CLI
02 Node introduction
Getting Started with the Angular 2 CLI
Node js for beginners
Node js introduction
An afternoon with angular 2
Ad

Similar to Rits Brown Bag - TypeScript (20)

PPTX
Getting started with typescript
PPTX
TypeScript Overview
PDF
TypeScript introduction to scalable javascript application
PDF
Reasons to Use Typescript for Your Next Project Over Javascript.pdf
PDF
Introduction to TypeScript
PPTX
Typescript ppt
PPTX
TypeScript-SPS-melb.pptx
PPTX
TypeScript: Basic Features and Compilation Guide
PPTX
Typescript: Beginner to Advanced
PPTX
Type script
PDF
TypeScipt - Get Started
PDF
4Developers: Tomasz Ducin- JavaScript + Java = TypeScript
PPTX
Complete Notes on Angular 2 and TypeScript
PPTX
PPTX
TypeScript . the JavaScript developer best friend!
PDF
An Introduction to TypeScript
PPTX
Type script - advanced usage and practices
PPTX
Typescript language extension of java script
PDF
TypeScript: coding JavaScript without the pain
PPTX
Typescript in 30mins
Getting started with typescript
TypeScript Overview
TypeScript introduction to scalable javascript application
Reasons to Use Typescript for Your Next Project Over Javascript.pdf
Introduction to TypeScript
Typescript ppt
TypeScript-SPS-melb.pptx
TypeScript: Basic Features and Compilation Guide
Typescript: Beginner to Advanced
Type script
TypeScipt - Get Started
4Developers: Tomasz Ducin- JavaScript + Java = TypeScript
Complete Notes on Angular 2 and TypeScript
TypeScript . the JavaScript developer best friend!
An Introduction to TypeScript
Type script - advanced usage and practices
Typescript language extension of java script
TypeScript: coding JavaScript without the pain
Typescript in 30mins

More from Right IT Services (15)

PDF
Rits Brown Bag - React Native and Salesforce
PDF
Rits Brown Bag - Conga Composer
PPTX
Rits Brown Bag - Environment MS Dynamics CRM
PPTX
Rits Brown Bag - Google AdWords Basics
PPTX
Salesforce.com Continuous Integration
PDF
Rits Brown Bag - SharePoint 2016
PDF
Rits Brown Bag - vtiger
PDF
Rits Brown Bag - Salesforce Social Studio
PDF
Rits Brown Bag - Introduction to SharePoint
PDF
Workbook for Lightning Developers
PDF
Rits Brown Bag - Surveys and Polls Techniques
PDF
Rits Brown Bag - Salesforce Lightning External Connection
PDF
Rits Brown Bag - Anatomy of a Mobile App
PDF
Rits Brown Bag - Salesforce Duplicate Management
PDF
Rits Brown Bag - Salesforce AppExchange
Rits Brown Bag - React Native and Salesforce
Rits Brown Bag - Conga Composer
Rits Brown Bag - Environment MS Dynamics CRM
Rits Brown Bag - Google AdWords Basics
Salesforce.com Continuous Integration
Rits Brown Bag - SharePoint 2016
Rits Brown Bag - vtiger
Rits Brown Bag - Salesforce Social Studio
Rits Brown Bag - Introduction to SharePoint
Workbook for Lightning Developers
Rits Brown Bag - Surveys and Polls Techniques
Rits Brown Bag - Salesforce Lightning External Connection
Rits Brown Bag - Anatomy of a Mobile App
Rits Brown Bag - Salesforce Duplicate Management
Rits Brown Bag - Salesforce AppExchange

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
KodekX | Application Modernization Development
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Approach and Philosophy of On baking technology
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
cuic standard and advanced reporting.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
MIND Revenue Release Quarter 2 2025 Press Release
KodekX | Application Modernization Development
The AUB Centre for AI in Media Proposal.docx
NewMind AI Weekly Chronicles - August'25 Week I
Approach and Philosophy of On baking technology
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
cuic standard and advanced reporting.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Per capita expenditure prediction using model stacking based on satellite ima...
Network Security Unit 5.pdf for BCA BBA.
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Encapsulation theory and applications.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf

Rits Brown Bag - TypeScript

  • 1. © 2016, Right IT Services. All rights reserved TypeScript Friday, 02 December 2016
  • 2. 2 What’s TypeScript? TypeScript First appered 2012 Free and OpenSource project by Microsoft Created by the father of C# Anders Hejlsberg Typed superset of JavaScript A new language that compiles to plain JavaScript ES3 - ES5, ES6 2009
  • 3. 3 Friends - Who’s Using TypeScript? TypeScript
  • 5. 5 Why TypeScript? JS is interpreted, not compiled There are no design-time intellisense or compile-time assistance to help you point out errors A function is your contract with your caller Function with parameters are more like guidelines Global Scope Why is the method called includes and not contains in Array? MooTools adds this method to Array.prototype. Scope TypeScript function func(anyvar) { console.log(arguments.length); return anyvar+ 1; } func(); func(“Change to TypeScript"); func("Change to", "TypeScript"); func(function(){}); f(1,2,3,4,5); //5 var foo = 1; function test1() { foo = 2; console.log(foo); }; test1(); console.log(foo); var foo = 3; function test2() { var foo = 4; console.log(foo); }; test2(); console.log(foo);
  • 6. 6 Why TypeScript? Object extension Object inheritance is possible, but too messy Some pitfalls TypeScript var a = "2"; var b = "2"; var c = a * b; //4 var a = "a"; var b = "b"; var c = a * b; //NaN console.log('4' - 4); console.log('4' + 4); //0 //44 undefined == undefined //true null == undefined //true null === undefined //false 0 == undefined //false ”” == undefined //false false == undefined //false false == 0 //true false == ”” //true void 0 var x = { a : 1, b : 2 } x.c = 3; console.log(x[“a”] + x.b + x.c);
  • 7. 7 Features of TypeScript Namespaces & Modules Nomenclature has changed Align with ECMAScript 2015 TypeScript namespace Animal { export namespace Domestic { export function move(distance: number): boolean { } } } var moved = Animal.Domestic.move(100);
  • 8. 8 Features of TypeScript Interfaces TypeScript enum Direction{ Right = 0, Left = 1 } interface Animal { name: string; age: number; domestic: boolean; } interface Animal { move(distance: number, direction: Direction); } export class Cat implements Animal{ ... }
  • 9. 9 TypeScript Features Abstract & Classes TypeScript abstract class Animal { abstract getName(): string; } class Cat extends Animal { constructor() { super(); } public getName(): string { return ""; } } class Dog extends Animal { constructor() { super(); } getName(): string { return ""; } } class Kennel<T extends Animal> { getName<T extends Animal>(animal: T) : string { return animal.getName(); } } var cat = new Cat(); var dog: Dog = new Dog(); var kennel = new Kennel(); var animal1 = kennel.getName(cat); var animal2 = kennel.getName(dog);
  • 10. 10 TypeScript Features Variable Scoping TypeScript for (var i = 0; i < this.length; i++) { … } for (var i = 0; i < this.length; i++) { //Error … } if(this.length > 0) { let self = this[1]; //scoped only to if conditional }
  • 11. 11 TypeScript Features Declaration Files .d.ts files containing declarative statements to describe TypeScript modules, classes, objects, etc. Definition files for common JavaScript libraries makes them very easy to work with, and provides strong type checking TypeScript
  • 12. 12 TypeScript Declaration Files Variable Scoping TypeScript for (var i = 0; i < this.length; i++) { … } for (var i = 0; i < this.length; i++) { //Error … } if(this.length > 0) { let self = this[1]; //scoped only to if conditional }
  • 13. 13 Problems TypeScript Solves Type safety All the features are optionals We can not use types All valid JavaScript is valid TypeScript Modules TypeScript module outer { var str = "hello world"; } var outer; (function (outer) { var str = "hello world"; })(outer || (outer = {}));
  • 14. 14 Problems TypeScript Solves Checks Types Less Runtime Bugs Less Unit Tests assert.isString assert.isNumber TypeScript
  • 15. 15 Problems TypeScript Doesn’t Solve Mistakes Logical mistakes Lack of knowledge Still need to understand JS TS without knowing JS == disaster what output will TS provide? Won't make it faster Won't make you code faster Won't make app run faster The any type Stands for NO TYPE Very easy and tempting to use Will spoil your app if used in big amounts Debug browsers don't execute TS source and output: different TypeScript
  • 17. WHEN YOU HAVE TO DO IT, DO IT RIGHT © 2016, Right IT Services. All rights reserved Rua Odette Saint Maurice Lote 3B | Edifício L | Escritório A | Piso -1 | 1700-097 Lisboa | Portugal | +351 218 232 261 Pedro Azevedo – Technical Lead Dynamics CRM Environment Microsoft Dynamics CRM Friday, 02 December 2016 TypeScript