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

PPTX
Typescript ppt
akhilsreyas
 
PDF
TypeScript - An Introduction
NexThoughts Technologies
 
PDF
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
PPTX
Typescript Fundamentals
Sunny Sharma
 
PPTX
Modern JS with ES6
Kevin Langley Jr.
 
PPTX
TypeScript Overview
Aniruddha Chakrabarti
 
PDF
Javascript Arrow function
tanerochris
 
PDF
Angular - Chapter 1 - Introduction
WebStackAcademy
 
Typescript ppt
akhilsreyas
 
TypeScript - An Introduction
NexThoughts Technologies
 
TypeScript: coding JavaScript without the pain
Sander Mak (@Sander_Mak)
 
Typescript Fundamentals
Sunny Sharma
 
Modern JS with ES6
Kevin Langley Jr.
 
TypeScript Overview
Aniruddha Chakrabarti
 
Javascript Arrow function
tanerochris
 
Angular - Chapter 1 - Introduction
WebStackAcademy
 

What's hot (20)

PPTX
Typescript in 30mins
Udaya Kumar
 
PPT
TypeScript Presentation
Patrick John Pacaña
 
PDF
TypeScript Best Practices
felixbillon
 
PPTX
Introducing type script
Remo Jansen
 
PPTX
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
PPTX
Why TypeScript?
FITC
 
PDF
The New JavaScript: ES6
Rob Eisenberg
 
PPTX
TypeScript
Udaiappa Ramachandran
 
PDF
jQuery for beginners
Arulmurugan Rajaraman
 
PDF
Asynchronous JavaScript Programming
Haim Michael
 
PPTX
[Final] ReactJS presentation
洪 鹏发
 
PDF
Introduction into ES6 JavaScript.
boyney123
 
PPT
Advanced Javascript
Adieu
 
PPTX
TypeScript intro
Ats Uiboupin
 
PDF
TypeScript
Saray Chak
 
PPTX
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
PDF
Introduction to ASP.NET Core
Avanade Nederland
 
PDF
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
PPT
Introduction to Javascript
Amit Tyagi
 
PPTX
Node.js Express
Eyal Vardi
 
Typescript in 30mins
Udaya Kumar
 
TypeScript Presentation
Patrick John Pacaña
 
TypeScript Best Practices
felixbillon
 
Introducing type script
Remo Jansen
 
Getting started with typescript
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
Why TypeScript?
FITC
 
The New JavaScript: ES6
Rob Eisenberg
 
jQuery for beginners
Arulmurugan Rajaraman
 
Asynchronous JavaScript Programming
Haim Michael
 
[Final] ReactJS presentation
洪 鹏发
 
Introduction into ES6 JavaScript.
boyney123
 
Advanced Javascript
Adieu
 
TypeScript intro
Ats Uiboupin
 
TypeScript
Saray Chak
 
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
Introduction to ASP.NET Core
Avanade Nederland
 
Fundamental JavaScript [UTC, March 2014]
Aaron Gustafson
 
Introduction to Javascript
Amit Tyagi
 
Node.js Express
Eyal Vardi
 
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)

KEY
Coffee Scriptでenchant.js
Naoyuki Totani
 
PPTX
JSLounge - TypeScript 소개
Reagan Hwang
 
PDF
Mini-curso JavaFX Aula2
Raphael Marques
 
PDF
Say It With Javascript
Giovanni Scerra ☃
 
PPTX
Introduction to TypeScript
Tomas Corral Casas
 
PPTX
Type script, for dummies
santiagoaguiar
 
PDF
A la découverte de TypeScript
Denis Voituron
 
PDF
The Future of JavaScript (Ajax Exp '07)
jeresig
 
PPTX
TypeScript by Howard
LearningTech
 
PPTX
Howard type script
LearningTech
 
PPTX
Type script by Howard
LearningTech
 
PDF
TypeScript Introduction
Hans Höchtl
 
PDF
Tamarin And Ecmascript 4
elliando dias
 
PDF
FITC CoffeeScript 101
Faisal Abid
 
PPTX
TypeScript
Oswald Campesato
 
PPT
Typescript - why it's awesome
Piotr Miazga
 
PPTX
Academy PRO: ES2015
Binary Studio
 
PPTX
Typescript - A developer friendly javascript
pradiphudekar
 
PDF
Javascript
Vlad Ifrim
 
PPTX
Advanced JavaScript
Zsolt Mészárovics
 
Coffee Scriptでenchant.js
Naoyuki Totani
 
JSLounge - TypeScript 소개
Reagan Hwang
 
Mini-curso JavaFX Aula2
Raphael Marques
 
Say It With Javascript
Giovanni Scerra ☃
 
Introduction to TypeScript
Tomas Corral Casas
 
Type script, for dummies
santiagoaguiar
 
A la découverte de TypeScript
Denis Voituron
 
The Future of JavaScript (Ajax Exp '07)
jeresig
 
TypeScript by Howard
LearningTech
 
Howard type script
LearningTech
 
Type script by Howard
LearningTech
 
TypeScript Introduction
Hans Höchtl
 
Tamarin And Ecmascript 4
elliando dias
 
FITC CoffeeScript 101
Faisal Abid
 
TypeScript
Oswald Campesato
 
Typescript - why it's awesome
Piotr Miazga
 
Academy PRO: ES2015
Binary Studio
 
Typescript - A developer friendly javascript
pradiphudekar
 
Javascript
Vlad Ifrim
 
Advanced JavaScript
Zsolt Mészárovics
 

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
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
Doc9.....................................
SofiaCollazos
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
Software Development Company | KodekX
KodekX
 
Software Development Methodologies in 2025
KodekX
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
This slide provides an overview Technology
mineshkharadi333
 
Doc9.....................................
SofiaCollazos
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Coupa-Overview _Assumptions presentation
annapureddyn
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 

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