SlideShare a Scribd company logo
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
TypeScript Introduction
var inx: number = 1,
   text: string = “Lorem”,
   isReady: bool = false,
   arr: string[],
   obj: ObjInterface = factory.getObj(),
   mixedVal: any;
var obj: { x: number, y: number },
   fn: ( x: number, y?: any ) => number,
   constr: new() => ObjInterface;
var treatItems = function( arr,
    callback ) {
   // do something
   return arr;
};
var treatItems = function(
   arr: string[],
   callback: (value: string,
              inx: number,
              arr: string[]) => string[]) {
       // do something
       return arr;
};
var treatItems = function( arr,
    callback ) {
   // do something
   return arr;
};
TypeScript Introduction
class Mamal
{
  private nickname: string;

    constructor( nickname: string = "Noname" ) {
      this.nickname = nickname;
    }

    public getNickname():string {
      return this.nickname;
    }
}
class Cat extends Mamal
{
  private family: string = "Felidae";

    constructor( nickname: string ) {
      super( nickname );
    }

    public getFamily():string {
      return this.family;
    }
}
// Generated JavaScript: helper

var __extends = this.__extends || function (d,
b) {
  function __() { this.constructor = d; }
  __.prototype = b.prototype;
  d.prototype = new __();
}
// Generated JavaScript: classes

var Mamal = (function () { … })();
var Cat = (function (_super) {
  __extends(Cat, _super);
  function Cat(nickname) {
     _super.call(this, nickname);
     this.family = "Felidae";
  }
  Cat.prototype.getFamily = function () {
     return this.family;
  };
  return Cat;
})(Mamal);
TypeScript Introduction
interface Point {
  x: number;
  y: number;
}

function getDistance( pointA: Point, pointB: Point ) {
  return Math.sqrt(
         Math.pow( pointB.x - pointA.x, 2 ) +
         Math.pow( pointB.y - pointA.y, 2 )
      );
}

var result = getDistance(
       { x: - 2, y: - 3 }, { x: - 4, y: 4 })
interface Mover
{
  move(): void;
}
interface Shaker
{
  shake(): void;
}
interface MoverShaker extends Mover, Shaker
{
}
TypeScript Introduction
module graphic
{
       export class Point
       {
              x: number;
              y: number;
              constructor( x: number = 0, y: number = 0 )
              {
              };
       }
}
var point = new graphic.Point( 10, 10 );
// File main.ts:
import log = module ( "log” );
log.message( "hello" );

// File log.js:
export function message(s: string) {
   console.log(s);
}
TypeScript Introduction
(x) => { return Math.sin(x); }
(x) => Math.sin(x);
x => { return Math.sin(x); }
x => Math.sin(x);
var messenger = {
   message: "Hello World",
   start: function() {
     setTimeout( () =>
       { alert( this.message ); }, 3000 );
   }
};
messenger.start();
TypeScript Introduction
class Shape { ... }
class Circle extends Shape { ... }

function createShape( kind: string ): Shape {
      if ( kind === "circle" ) return new Circle(); ...
}

var circle = <Circle> createShape( "circle" );
TypeScript Introduction
interface JQuery
{
       text(content: string);
}
interface JQueryStatic {
       get(url: string, callback: (data: string) => any);
       (query: string): JQuery;
}
declare var $: JQueryStatic;
TypeScript Introduction
/// <reference path="jquery.d.ts" />
module Parallax
{
  export class ParallaxContainer
  {
    private content: HTMLElement;

    constructor( scrollableContent: HTMLElement ) {
      $( scrollableContent ).scroll(( event: JQueryEventObject ) => {
        this.onContainerScroll( event );
      });
    }

    private onContainerScroll( e: JQueryEventObject ) : void {
      // do something
    }
}
gist.github.com/3845543
TypeScript Introduction
TypeScript Introduction
https://github.com/joyent/node/wiki/In
    stalling-Node.js-via-package-
               manager
npm install -g typescript
tsc example.ts
tsc --target ES5 example.ts
https://github.com/niutech/typescript-
                compile
TypeScript Introduction
<?xml version="1.0"?>
<!DOCTYPE project>
<project name="tsc" basedir="." default="build">
  <target name="build">
    <!-- Compile all .ts files -->
    <apply executable="tsc" parallel="true">
      <srcfile/>
      <fileset dir="." includes="**/*.ts"/>
    </apply>
   <!-- Lint all required CSS, JS files -->
    <!-- Concatenate all required CSS, JS files -->
    <!-- Compress built CSS, JS files -->
  </target>
</project>
ant
TypeScript Introduction

More Related Content

PDF
TypeScript - An Introduction
NexThoughts Technologies
 
PPT
Html presentation
Amber Bhaumik
 
PPTX
Session Hijacking
n|u - The Open Security Community
 
PDF
Introduction to Redux
Ignacio Martín
 
PPTX
React workshop
Imran Sayed
 
PDF
Boas Práticas em Segurança da Informação
Rodrigo Bueno Santa Maria, BS, MBA
 
TypeScript - An Introduction
NexThoughts Technologies
 
Html presentation
Amber Bhaumik
 
Introduction to Redux
Ignacio Martín
 
React workshop
Imran Sayed
 
Boas Práticas em Segurança da Informação
Rodrigo Bueno Santa Maria, BS, MBA
 

What's hot (20)

PPT
TypeScript Presentation
Patrick John Pacaña
 
PPTX
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
PPTX
Typescript ppt
akhilsreyas
 
PPTX
TypeScript Overview
Aniruddha Chakrabarti
 
PPTX
TypeScript intro
Ats Uiboupin
 
PPTX
Why TypeScript?
FITC
 
PPTX
Typescript Fundamentals
Sunny Sharma
 
PPTX
Introducing type script
Remo Jansen
 
PDF
TypeScript Best Practices
felixbillon
 
PDF
Asynchronous JavaScript Programming with Callbacks & Promises
Hùng Nguyễn Huy
 
PDF
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
PPTX
Typescript in 30mins
Udaya Kumar
 
PPTX
Angular overview
Thanvilahari
 
PPTX
TypeScript: Basic Features and Compilation Guide
Nascenia IT
 
PPT
Javascript
Manav Prasad
 
PPT
Introduction to Javascript
Amit Tyagi
 
PPTX
JavaScript Promises
L&T Technology Services Limited
 
PDF
TypeScript
Saray Chak
 
PPTX
TypeScript
Udaiappa Ramachandran
 
TypeScript Presentation
Patrick John Pacaña
 
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
Typescript ppt
akhilsreyas
 
TypeScript Overview
Aniruddha Chakrabarti
 
TypeScript intro
Ats Uiboupin
 
Why TypeScript?
FITC
 
Typescript Fundamentals
Sunny Sharma
 
Introducing type script
Remo Jansen
 
TypeScript Best Practices
felixbillon
 
Asynchronous JavaScript Programming with Callbacks & Promises
Hùng Nguyễn Huy
 
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
NodeJS for Beginner
Apaichon Punopas
 
Typescript in 30mins
Udaya Kumar
 
Angular overview
Thanvilahari
 
TypeScript: Basic Features and Compilation Guide
Nascenia IT
 
Javascript
Manav Prasad
 
Introduction to Javascript
Amit Tyagi
 
JavaScript Promises
L&T Technology Services Limited
 
TypeScript
Saray Chak
 
Ad

Viewers also liked (16)

PDF
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
MoscowJS
 
PPTX
TypeScript - Silver Bullet for the Full-stack Developers
Rutenis Turcinas
 
PPTX
002. Introducere in type script
Dmitrii Stoian
 
PDF
TypeScript: Angular's Secret Weapon
Laurent Duveau
 
PPTX
Typescript
Nikhil Thomas
 
PPTX
Typescript tips & tricks
Ori Calvo
 
PDF
Power Leveling your TypeScript
Offirmo
 
PDF
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
Micael Gallego
 
PPTX
TypeScript
GetDev.NET
 
PDF
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
Ontico
 
PDF
TypeScript Seminar
Haim Michael
 
PDF
Angular 2 - Typescript
Nathan Krasney
 
PDF
TypeScript for Java Developers
Yakov Fain
 
PDF
Александр Русаков - TypeScript 2 in action
MoscowJS
 
PDF
Typescript + Graphql = <3
felixbillon
 
PDF
TypeScriptで快適javascript
AfiruPain NaokiSoga
 
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
MoscowJS
 
TypeScript - Silver Bullet for the Full-stack Developers
Rutenis Turcinas
 
002. Introducere in type script
Dmitrii Stoian
 
TypeScript: Angular's Secret Weapon
Laurent Duveau
 
Typescript
Nikhil Thomas
 
Typescript tips & tricks
Ori Calvo
 
Power Leveling your TypeScript
Offirmo
 
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
Micael Gallego
 
TypeScript
GetDev.NET
 
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
Ontico
 
TypeScript Seminar
Haim Michael
 
Angular 2 - Typescript
Nathan Krasney
 
TypeScript for Java Developers
Yakov Fain
 
Александр Русаков - TypeScript 2 in action
MoscowJS
 
Typescript + Graphql = <3
felixbillon
 
TypeScriptで快適javascript
AfiruPain NaokiSoga
 
Ad

Similar to TypeScript Introduction (20)

PDF
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
PPTX
ES6 Overview
Bruno Scopelliti
 
PDF
Functional programming using underscorejs
偉格 高
 
PDF
The Beauty Of Java Script V5a
rajivmordani
 
PDF
JavaScript - Agora nervoso
Luis Vendrame
 
PDF
The Beauty of Java Script
Michael Girouard
 
PPT
SDC - Einführung in Scala
Christian Baranowski
 
PPTX
EcmaScript unchained
Eduard Tomàs
 
PDF
Bindings: the zen of montage
Kris Kowal
 
PPSX
What's New In C# 7
Paulo Morgado
 
PDF
ES6, WTF?
James Ford
 
PDF
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
PPTX
Academy PRO: ES2015
Binary Studio
 
PDF
Scala in practice
andyrobinson8
 
KEY
Object-Oriented JavaScript
kvangork
 
KEY
Object-Oriented Javascript
kvangork
 
PDF
AJUG April 2011 Cascading example
Christopher Curtin
 
PPTX
Type script, for dummies
santiagoaguiar
 
PPTX
Advanced JavaScript
Zsolt Mészárovics
 
PDF
ES6 patterns in the wild
Joe Morgan
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
ES6 Overview
Bruno Scopelliti
 
Functional programming using underscorejs
偉格 高
 
The Beauty Of Java Script V5a
rajivmordani
 
JavaScript - Agora nervoso
Luis Vendrame
 
The Beauty of Java Script
Michael Girouard
 
SDC - Einführung in Scala
Christian Baranowski
 
EcmaScript unchained
Eduard Tomàs
 
Bindings: the zen of montage
Kris Kowal
 
What's New In C# 7
Paulo Morgado
 
ES6, WTF?
James Ford
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
Academy PRO: ES2015
Binary Studio
 
Scala in practice
andyrobinson8
 
Object-Oriented JavaScript
kvangork
 
Object-Oriented Javascript
kvangork
 
AJUG April 2011 Cascading example
Christopher Curtin
 
Type script, for dummies
santiagoaguiar
 
Advanced JavaScript
Zsolt Mészárovics
 
ES6 patterns in the wild
Joe Morgan
 

More from Dmitry Sheiko (7)

PPTX
The Flavor of TypeScript
Dmitry Sheiko
 
PPTX
Writing Scalable and Maintainable CSS
Dmitry Sheiko
 
PDF
Tooling JavaScript to ensure consistency in coding style
Dmitry Sheiko
 
PDF
JavaScript MV* Framework - Making the Right Choice
Dmitry Sheiko
 
PDF
Modular JavaScript with CommonJS Compiler
Dmitry Sheiko
 
PDF
A Quick Start - Version Control with Git
Dmitry Sheiko
 
PPTX
Bringing classical OOP into JavaScript
Dmitry Sheiko
 
The Flavor of TypeScript
Dmitry Sheiko
 
Writing Scalable and Maintainable CSS
Dmitry Sheiko
 
Tooling JavaScript to ensure consistency in coding style
Dmitry Sheiko
 
JavaScript MV* Framework - Making the Right Choice
Dmitry Sheiko
 
Modular JavaScript with CommonJS Compiler
Dmitry Sheiko
 
A Quick Start - Version Control with Git
Dmitry Sheiko
 
Bringing classical OOP into JavaScript
Dmitry Sheiko
 

Recently uploaded (20)

PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PPTX
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
The Future of Artificial Intelligence (AI)
Mukul
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
The-Ethical-Hackers-Imperative-Safeguarding-the-Digital-Frontier.pptx
sujalchauhan1305
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 

TypeScript Introduction

  • 17. var inx: number = 1, text: string = “Lorem”, isReady: bool = false, arr: string[], obj: ObjInterface = factory.getObj(), mixedVal: any;
  • 18. var obj: { x: number, y: number }, fn: ( x: number, y?: any ) => number, constr: new() => ObjInterface;
  • 19. var treatItems = function( arr, callback ) { // do something return arr; };
  • 20. var treatItems = function( arr: string[], callback: (value: string, inx: number, arr: string[]) => string[]) { // do something return arr; };
  • 21. var treatItems = function( arr, callback ) { // do something return arr; };
  • 23. class Mamal { private nickname: string; constructor( nickname: string = "Noname" ) { this.nickname = nickname; } public getNickname():string { return this.nickname; } }
  • 24. class Cat extends Mamal { private family: string = "Felidae"; constructor( nickname: string ) { super( nickname ); } public getFamily():string { return this.family; } }
  • 25. // Generated JavaScript: helper var __extends = this.__extends || function (d, b) { function __() { this.constructor = d; } __.prototype = b.prototype; d.prototype = new __(); }
  • 26. // Generated JavaScript: classes var Mamal = (function () { … })(); var Cat = (function (_super) { __extends(Cat, _super); function Cat(nickname) { _super.call(this, nickname); this.family = "Felidae"; } Cat.prototype.getFamily = function () { return this.family; }; return Cat; })(Mamal);
  • 28. interface Point { x: number; y: number; } function getDistance( pointA: Point, pointB: Point ) { return Math.sqrt( Math.pow( pointB.x - pointA.x, 2 ) + Math.pow( pointB.y - pointA.y, 2 ) ); } var result = getDistance( { x: - 2, y: - 3 }, { x: - 4, y: 4 })
  • 29. interface Mover { move(): void; } interface Shaker { shake(): void; } interface MoverShaker extends Mover, Shaker { }
  • 31. module graphic { export class Point { x: number; y: number; constructor( x: number = 0, y: number = 0 ) { }; } } var point = new graphic.Point( 10, 10 );
  • 32. // File main.ts: import log = module ( "log” ); log.message( "hello" ); // File log.js: export function message(s: string) { console.log(s); }
  • 34. (x) => { return Math.sin(x); } (x) => Math.sin(x); x => { return Math.sin(x); } x => Math.sin(x);
  • 35. var messenger = { message: "Hello World", start: function() { setTimeout( () => { alert( this.message ); }, 3000 ); } }; messenger.start();
  • 37. class Shape { ... } class Circle extends Shape { ... } function createShape( kind: string ): Shape { if ( kind === "circle" ) return new Circle(); ... } var circle = <Circle> createShape( "circle" );
  • 39. interface JQuery { text(content: string); } interface JQueryStatic { get(url: string, callback: (data: string) => any); (query: string): JQuery; } declare var $: JQueryStatic;
  • 41. /// <reference path="jquery.d.ts" /> module Parallax { export class ParallaxContainer { private content: HTMLElement; constructor( scrollableContent: HTMLElement ) { $( scrollableContent ).scroll(( event: JQueryEventObject ) => { this.onContainerScroll( event ); }); } private onContainerScroll( e: JQueryEventObject ) : void { // do something } }
  • 45. https://github.com/joyent/node/wiki/In stalling-Node.js-via-package- manager
  • 46. npm install -g typescript
  • 48. tsc --target ES5 example.ts
  • 51. <?xml version="1.0"?> <!DOCTYPE project> <project name="tsc" basedir="." default="build"> <target name="build"> <!-- Compile all .ts files --> <apply executable="tsc" parallel="true"> <srcfile/> <fileset dir="." includes="**/*.ts"/> </apply> <!-- Lint all required CSS, JS files --> <!-- Concatenate all required CSS, JS files --> <!-- Compress built CSS, JS files --> </target> </project>
  • 52. ant