SlideShare une entreprise Scribd logo
1  sur  53
Télécharger pour lire hors ligne
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;
};
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);
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
{
}
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);
}
(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();
class Shape { ... }
class Circle extends Shape { ... }

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

var circle = <Circle> createShape( "circle" );
interface JQuery
{
       text(content: string);
}
interface JQueryStatic {
       get(url: string, callback: (data: string) => any);
       (query: string): JQuery;
}
declare var $: JQueryStatic;
/// <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
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
<?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

Contenu connexe

Tendances

Tendances (20)

TypeScript intro
TypeScript introTypeScript intro
TypeScript intro
 
TypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideTypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation Guide
 
Introducing type script
Introducing type scriptIntroducing type script
Introducing type script
 
Typescript Fundamentals
Typescript FundamentalsTypescript Fundamentals
Typescript Fundamentals
 
TypeScript Overview
TypeScript OverviewTypeScript Overview
TypeScript Overview
 
Getting started with typescript
Getting started with typescriptGetting started with typescript
Getting started with typescript
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
TypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptxTypeScript VS JavaScript.pptx
TypeScript VS JavaScript.pptx
 
Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practices
 
ES6 presentation
ES6 presentationES6 presentation
ES6 presentation
 
Node.js Express
Node.js  ExpressNode.js  Express
Node.js Express
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Nodejs functions & modules
Nodejs functions & modulesNodejs functions & modules
Nodejs functions & modules
 
Introduction to Node.js
Introduction to Node.jsIntroduction to Node.js
Introduction to Node.js
 
JavaScript Promises
JavaScript PromisesJavaScript Promises
JavaScript Promises
 
TypeScript
TypeScriptTypeScript
TypeScript
 
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
Node.js Tutorial for Beginners | Node.js Web Application Tutorial | Node.js T...
 
React-JS Component Life-cycle Methods
React-JS Component Life-cycle MethodsReact-JS Component Life-cycle Methods
React-JS Component Life-cycle Methods
 
NEXT.JS
NEXT.JSNEXT.JS
NEXT.JS
 
Learning typescript
Learning typescriptLearning typescript
Learning typescript
 

En vedette

En vedette (16)

«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
 
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
 
002. Introducere in type script
002. Introducere in type script002. Introducere in type script
002. Introducere in type script
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
 
Typescript
TypescriptTypescript
Typescript
 
Typescript tips & tricks
Typescript tips & tricksTypescript tips & tricks
Typescript tips & tricks
 
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
TypeScriptTypeScript
TypeScript
 
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
 
TypeScript Seminar
TypeScript SeminarTypeScript Seminar
TypeScript Seminar
 
Angular 2 - Typescript
Angular 2  - TypescriptAngular 2  - Typescript
Angular 2 - Typescript
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
 
Александр Русаков - TypeScript 2 in action
Александр Русаков - TypeScript 2 in actionАлександр Русаков - TypeScript 2 in action
Александр Русаков - TypeScript 2 in action
 
Typescript + Graphql = <3
Typescript + Graphql = <3Typescript + Graphql = <3
Typescript + Graphql = <3
 
TypeScriptで快適javascript
TypeScriptで快適javascriptTypeScriptで快適javascript
TypeScriptで快適javascript
 

Similaire à TypeScript Introduction

HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
偉格 高
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
rajivmordani
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montage
Kris Kowal
 

Similaire à TypeScript Introduction (20)

HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
 
Functional programming using underscorejs
Functional programming using underscorejsFunctional programming using underscorejs
Functional programming using underscorejs
 
The Beauty Of Java Script V5a
The Beauty Of Java Script V5aThe Beauty Of Java Script V5a
The Beauty Of Java Script V5a
 
JavaScript - Agora nervoso
JavaScript - Agora nervosoJavaScript - Agora nervoso
JavaScript - Agora nervoso
 
The Beauty of Java Script
The Beauty of Java ScriptThe Beauty of Java Script
The Beauty of Java Script
 
SDC - Einführung in Scala
SDC - Einführung in ScalaSDC - Einführung in Scala
SDC - Einführung in Scala
 
EcmaScript unchained
EcmaScript unchainedEcmaScript unchained
EcmaScript unchained
 
Bindings: the zen of montage
Bindings: the zen of montageBindings: the zen of montage
Bindings: the zen of montage
 
What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7
 
ES6, WTF?
ES6, WTF?ES6, WTF?
ES6, WTF?
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
 
Academy PRO: ES2015
Academy PRO: ES2015Academy PRO: ES2015
Academy PRO: ES2015
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
Object-Oriented Javascript
Object-Oriented JavascriptObject-Oriented Javascript
Object-Oriented Javascript
 
AJUG April 2011 Cascading example
AJUG April 2011 Cascading exampleAJUG April 2011 Cascading example
AJUG April 2011 Cascading example
 
Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummies
 
Advanced JavaScript
Advanced JavaScript Advanced JavaScript
Advanced JavaScript
 
ES6 patterns in the wild
ES6 patterns in the wildES6 patterns in the wild
ES6 patterns in the wild
 

Plus de Dmitry Sheiko

Plus de Dmitry Sheiko (7)

The Flavor of TypeScript
The Flavor of TypeScriptThe Flavor of TypeScript
The Flavor of TypeScript
 
Writing Scalable and Maintainable CSS
Writing Scalable and Maintainable CSSWriting Scalable and Maintainable CSS
Writing Scalable and Maintainable CSS
 
Tooling JavaScript to ensure consistency in coding style
Tooling JavaScript to ensure consistency in coding styleTooling JavaScript to ensure consistency in coding style
Tooling JavaScript to ensure consistency in coding style
 
JavaScript MV* Framework - Making the Right Choice
JavaScript MV* Framework - Making the Right ChoiceJavaScript MV* Framework - Making the Right Choice
JavaScript MV* Framework - Making the Right Choice
 
Modular JavaScript with CommonJS Compiler
Modular JavaScript with CommonJS CompilerModular JavaScript with CommonJS Compiler
Modular JavaScript with CommonJS Compiler
 
A Quick Start - Version Control with Git
A Quick Start - Version Control with GitA Quick Start - Version Control with Git
A Quick Start - Version Control with Git
 
Bringing classical OOP into JavaScript
Bringing classical OOP into JavaScriptBringing classical OOP into JavaScript
Bringing classical OOP into JavaScript
 

Dernier

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Dernier (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

TypeScript Introduction

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 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; };
  • 22.
  • 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);
  • 27.
  • 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 { }
  • 30.
  • 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); }
  • 33.
  • 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();
  • 36.
  • 37. class Shape { ... } class Circle extends Shape { ... } function createShape( kind: string ): Shape { if ( kind === "circle" ) return new Circle(); ... } var circle = <Circle> createShape( "circle" );
  • 38.
  • 39. interface JQuery { text(content: string); } interface JQueryStatic { get(url: string, callback: (data: string) => any); (query: string): JQuery; } declare var $: JQueryStatic;
  • 40.
  • 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 } }
  • 43.
  • 44.
  • 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
  • 50.
  • 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