SlideShare a Scribd company logo
1 of 56
Download to read offline
À la découverte de
Denis Voituron
Agenda
• Installation
• JavaScript Strongly Typed
• Object Oriented Programming
• Find your Data with LINQ
• Asynchronous Programming
• Bests Practices
• Advantages and Disadvantages
• Conclusion
Historique
EcmaScript
ES8
(ES2017)
ES7
(ES2016)
ES6
(ES2015)
ES5
ES3
JavaScript
Problèmes du langage
• Langage interprété
• Absence de modules
• Typage faible
• Conversions automatiques
• Portée (this)
• Manque de types statiques
Programming language
Superset of JavaScript
Transpiled into JavaScript
Open Source
Developped by Microsoft, supported by Google
lang.org
«Microsoft's TypeScript may be the best of the
many Javascript front ends. It seems to generate
the most attractive code.»
https://insights.stackoverflow.com/survey/2018
Installation
Installation
• Visual Studio Code : https://code.visualstudio.com
• NodeJS et NPM : https://nodejs.org
• TypeScript :
• http-Server (Node) :
npm install TypeScript -g
npm install http-server -g
Reload Window
& Open TS file
Specifies the folder path containing
the tsserver and lib*.d.ts files to use.
Sample
function startGame() {
var myMessage = document.getElementById("message");
myMessage.innerText = "Hello world";
}
document.getElementById("btnStart").addEventListener("click", startGame);
HelloWorld.ts
<html>
<body>
<div id="message"></div>
<button id="btnStart">Start</button>
<script src="HelloWorld.js"></script>
</body>
</html>
Index.html
tsc HelloWorld.ts
tsconfig.json
• Target ECMAScript 5
• SourceMap Debugging in Chrome
• Strict Object is possibly 'null’
• Watch Run ‘tsc’ and update files
• …
{
"compilerOptions": {
"target": "es5",
"noImplicitAny": true,
"sourceMap": true,
"watch": true,
"strict": true,
"removeComments": true,
"outDir": "./dist"
},
"include": [
"./**/*.ts"
],
"exclude": [
"node_modules"
]
}
tsconfig.json
tsc --init
https://html5test.com
Tasks.json
Basic Types
Boolean - Number - String - Array - Enum
var name: string = "Denis"
var age: number = 21
var birthdate: Date;
var name = "Denis";
var age = 21;
var birthdate;
birthdate.
Declarations with let and const
console.log(someString);
var someString = "hello World";
let someString = "hello World";
console.log(someString);
const someString = "hello World";
someString = "a new World";
Type Annotations and Type Inference
let x: string = "Hello World";
x = 42;
let x = "Hello World";
x = 42;
let name: string = "Voituron";
let message = `My name is ${name}`;
Union Types, Null, Undefined
{
"compilerOptions": {
"strictNullChecks": true,
...
let x: string;
x = null;
x = undefined;
let y: string | null;
y = null;
y = undefined;
let z: string | number | null;
z = null;
z = "Hello";
z = 123;
Type Assertions
let value: any = 5;
let fixedString: string = (<number>value).toFixed(4);
console.log(fixedString) // 5.0000
let value: any = 5;
let fixedString: string = (value as number).toFixed(4);
console.log(fixedString) // 5.0000
Demo
+ showSolution(HTMLElement): void
+ play(): void
- checkSolution(): Boolean
+ static solution: RowOfBalls
+ static rows: RowOfBalls[ ]
+ color: Colors
+ isClickable: boolean
+ render(): HTMLImageElement
+ render(): HTMLElement
+ Red
+ Green
+ Yellow
+ Blue
+ White
+ balls: Ball[ ]
+ isClickable: boolean
+ goodBalls: number
+ render(): HTMLImageElement
Method
function getSurface(width: number): number {
return width * width;
}
function getSurface(width): number {
return width * width;
}
[ts] Parameter 'width' implicitly
has an 'any' type.
Overloaded Methods
// Signatures
function getSurface(width: number): number;
function getSurface(width: number, height: number): number;
// Main method
function getSurface(width: number, height?: number): number {
if (height == null)
return width * width;
else
return width * height;
}
Default value
function getSurface(width: number, height: number = width): number {
return width * height;
}
getSurface(10); // 100
getSurface(10, 5); // 50
Anonymous methods
let square = (x: number) => x * x;
square(2); // 4
let add = (a: number, b: number) => a + b;
add(2, 3); // 5
let add = (a: number, b: number) => { return a + b };
Static Members
class WebDeveloper extends Developer {
static jobDescription = "Build cool things";
static logFavoriteProtocol() {
console.log("HTTPS, of course");
}
writeTypeScript(): void {
console.log(WebDeveloper.jobDescription);
}
}
Generic
"lib": [ "es6" ]
let list = new Set<number>([0, 1]);
list.add(2)
let dico = new Map<string, number>([["k1", 0], ["k2", 1]]);
dico.set("k1", 2);
let array = new Array<string>();
array.push("Hello");
Generic
class Queue {
private data = [];
push = (item) => this.data.push(item);
pop = () => this.data.shift();
}
const queue = new Queue();
queue.push(0);
queue.push("1"); // RUNTIME ERROR
"lib": [ "es6" ]
Generic
class QueueNumber {
private data = [];
push = (item: number) => this.data.push(item);
pop = (): number => this.data.shift();
}
const queue = new QueueNumber();
queue.push(0);
queue.push("1"); // COMPILATION ERROR
class Queue<T> {
private data = [];
push = (item: T) => this.data.push(item);
pop = (): T => this.data.shift();
}
const queue = new Queue<number>();
queue.push(0);
queue.push("1"); // COMPILATION ERROR
Interfaces vs Classes
Classes
Define a new type
Properties (with implementation)
Methods (with implémentation)
Can be instantiated
Interfaces
Define a new type
Properties (signatures)
Methods (signatures)
Cannot be instantiated
Interfaces
interface Employee {
name: string;
title: string;
}
interface Manager extends Employee {
department: string;
numOfEmployees: number;
scheduleMeeting: (topic: string) => void;
}
let developer: Employee = {
name: "Voituron",
title: "Developer"
}
Classes
Module Oniryx.Myproject {
class Developer {
department: string;
private _title : string;
public get title() : string {
return this._title;
}
public set title(value : string) {
this._title = value;
}
public requirements(value: string): void {
console.log(value);
}
Extending a class, implementing an interface
class WebDeveloper extends Developer {
favoriteEditor: string;
writeTypeScript(): void {
// Write code
}
}
/// <reference path="Employee.ts" />
class Engineer implements Employee {
name: string;
title: string;
}
Constructors
class Developer {
public department: string;
public title: string;
constructor() {
console.log("Creating a new developer");
}
}
Constructors
class Developer {
public department: string;
public title: string;
constructor() {
console.log("Creating a new developer");
}
}
class WebDeveloper extends Developer {
readonly favoriteEditor: string;
constructor(editor: string) {
super();
this.favoriteEditor = editor;
}
}
Constructors
class Developer {
constructor(public department: string, public title: string) {
console.log("Creating a new developer");
}
}
class WebDeveloper extends Developer {
readonly favoriteEditor: string;
constructor(editor: string) {
super();
this.favoriteEditor = editor;
}
}
Extension methods
// global.d.ts
interface Date {
isInFuture(): boolean;
}
Date.prototype.isInFuture = function(): boolean {
return (this != null && this.valueOf() > Date.now());
}
Modules
• CommonJS
• SystemJS
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"traceResolution": true,
default
Exporting a declaration
export interface Person { }
class Manager { } // Not accessible outside the module
import { Person } from "./Person";
let manager: Person
Exporting a declaration
export interface Person { }
class Manager { } // Not accessible outside the module
import * as People from "./Person";
let manager: People.Person
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.21.0/system.js"></script>
<script>
SystemJS.config({
map: {
jquery: 'https://code.jquery.com/jquery.js'
},
packages: {
'.': { defaultExtension: 'js' }
}
});
SystemJS.import("./MyApp.js");
</script>
Module loader in browser
• Module are dynamically loaded (via SystemJS).
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.21.0/system.js"></script>
<script>
SystemJS.config({
map: {
jquery: 'https://code.jquery.com/jquery.js',
linqts: '/node_modules/linqts/dist/linqts.js'
},
packages: {
'.': { defaultExtension: 'js' }
}
});
SystemJS.import("./MyApp.js");
</script>
Linq for TypeScript
• SystemJS Loader
npm install linqts
https://github.com/kutyel/linq.ts
Linq for TypeScript https://github.com/kutyel/linq.ts
import { List } from "linqts"
const arr = new List<number>([1, 2, 3, 4, 5])
.Where(x => x > 3)
.Select(y => y * 2)
.ToArray(); // > [8, 10]
Linq for TypeScript https://github.com/kutyel/linq.ts
npm install linqts
import { List } from "linqts"
let people = new List([
{ Name: "Alice", Age: 25 },
{ Name: "Bob", Age: 50 },
{ Name: "Kathy", Age: 15 }
]);
let alice = people.FirstOrDefault(i => i.Age > 18).Name;
Linq for TypeScript https://github.com/kutyel/linq.ts
Project Select
Filter Where, Distinct
Test Any, All
Join Join
Group GroupBy, Group Join
Aggregate Count, Min, Max, Sum, Avg
Partition Skip, SkipWhile, Take, TakeWhile
Set Union, Intersect, Except
Order OrderBy, OrderByDescending
Async / Await
• Promiseclass HelloWorld {
public delay(ms: number): Promise<void> {
return new Promise<void>((resolve) => {
setTimeout(resolve, ms);
});
}
}
A Promise is an object representing the eventual
completion or failure of an asynchronous operation.
"compilerOptions": {
"target": "es5",
"lib": [
"es6", "dom"
]
},
Async / Await
• Promise
• async / await
class HelloWorld {
public delay(ms: number): Promise<void> {
return new Promise<void>((resolve) => {
setTimeout(resolve, ms);
});
}
public async asyncAwait(): Promise<void> {
document.write("Knock, knock! <br/>");
await this.delay(3000); // 3 seconds
document.write("Who's there? <br/>");
}
}
new HelloWorld().asyncAwait(); // Start
Compile and Build tsconfig.json
{
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [ "$tsc“ ],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
.vscodetasks.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"traceResolution": true,
"noImplicitAny": true,
"sourceMap": true,
"watch": true,
"strict": true,
"strictNullChecks": true,
"removeComments": true,
"outDir": "./dist",
"lib": [ "es6", "dom" ]
},
"include": [
"./**/*.ts"
],
"exclude": [
"node_modules"
]
}
<script type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.21.0/system.js">
</script>
<script>
SystemJS.config({
map: {
jquery: 'https://code.jquery.com/jquery.js',
linqts: '/node_modules/linqts/dist/linqts.js'
},
packages: {
'.': { defaultExtension: 'js' }
}
});
SystemJS.import("./MyApp.js");
</script>
Module Loader
Do's and Don'ts
• General Types
• Callback Types
• Optional Parameters in Callbacks
• Overloads and Callbacks
• Function Overloads
https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html
Programming language
Superset of JavaScript
Transpiled into JavaScript
Open Source
Developped by Microsoft, supported by Google
lang.org
Slides: https://slideshare.net/dvoituron
Code: https://github.com/dvoituron /TypeScriptMasterMind (branches)

More Related Content

What's hot

Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Sergey Tihon
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...Sang Don Kim
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroMohammad Shaker
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)omercomail
 
C++ vs C#
C++ vs C#C++ vs C#
C++ vs C#sudipv
 
A History of PHP
A History of PHPA History of PHP
A History of PHPXinchen Hui
 
Client side scripting using Javascript
Client side scripting using JavascriptClient side scripting using Javascript
Client side scripting using JavascriptBansari Shah
 
Csc1100 lecture15 ch09
Csc1100 lecture15 ch09Csc1100 lecture15 ch09
Csc1100 lecture15 ch09IIUM
 
BUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILERBUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILERAjeet Dubey
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbaivibrantuser
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersAlessandro Sanino
 
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...Journeys with Transmogrifier and friends or How not to get stuck in the Plone...
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...Daniel Jowett
 
How to build SDKs in Go
How to build SDKs in GoHow to build SDKs in Go
How to build SDKs in GoDiwaker Gupta
 
Vizwik Coding Manual
Vizwik Coding ManualVizwik Coding Manual
Vizwik Coding ManualVizwik
 

What's hot (20)

Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...Declarative authorization in REST services in SharePoint with F# and ServiceS...
Declarative authorization in REST services in SharePoint with F# and ServiceS...
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
C++ Windows Forms L01 - Intro
C++ Windows Forms L01 - IntroC++ Windows Forms L01 - Intro
C++ Windows Forms L01 - Intro
 
Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)Yacc (yet another compiler compiler)
Yacc (yet another compiler compiler)
 
C++ vs C#
C++ vs C#C++ vs C#
C++ vs C#
 
A History of PHP
A History of PHPA History of PHP
A History of PHP
 
Client side scripting using Javascript
Client side scripting using JavascriptClient side scripting using Javascript
Client side scripting using Javascript
 
Yacc lex
Yacc lexYacc lex
Yacc lex
 
Data file handling
Data file handlingData file handling
Data file handling
 
Csc1100 lecture15 ch09
Csc1100 lecture15 ch09Csc1100 lecture15 ch09
Csc1100 lecture15 ch09
 
BUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILERBUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILER
 
Php training100%placement-in-mumbai
Php training100%placement-in-mumbaiPhp training100%placement-in-mumbai
Php training100%placement-in-mumbai
 
Introduction to c_sharp
Introduction to c_sharpIntroduction to c_sharp
Introduction to c_sharp
 
LEX & YACC
LEX & YACCLEX & YACC
LEX & YACC
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
 
Files and streams
Files and streamsFiles and streams
Files and streams
 
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...Journeys with Transmogrifier and friends or How not to get stuck in the Plone...
Journeys with Transmogrifier and friends or How not to get stuck in the Plone...
 
How to build SDKs in Go
How to build SDKs in GoHow to build SDKs in Go
How to build SDKs in Go
 
Intro to .NET and Core C#
Intro to .NET and Core C#Intro to .NET and Core C#
Intro to .NET and Core C#
 
Vizwik Coding Manual
Vizwik Coding ManualVizwik Coding Manual
Vizwik Coding Manual
 

Similar to A la découverte de TypeScript

Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebMikel Torres Ugarte
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for CassandraEdward Capriolo
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"DataStax Academy
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch
 
JavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeJavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeLaurence Svekis ✔
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomerzefhemel
 
Boost delivery stream with code discipline engineering
Boost delivery stream with code discipline engineeringBoost delivery stream with code discipline engineering
Boost delivery stream with code discipline engineeringMiro Wengner
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensionserwanl
 
A miało być tak... bez wycieków
A miało być tak... bez wyciekówA miało być tak... bez wycieków
A miało być tak... bez wyciekówKonrad Kokosa
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#Bertrand Le Roy
 

Similar to A la découverte de TypeScript (20)

XAML/C# to HTML/JS
XAML/C# to HTML/JSXAML/C# to HTML/JS
XAML/C# to HTML/JS
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
Charla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo WebCharla EHU Noviembre 2014 - Desarrollo Web
Charla EHU Noviembre 2014 - Desarrollo Web
 
mobl
moblmobl
mobl
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
Getting Input from User
Getting Input from UserGetting Input from User
Getting Input from User
 
Unit-2 Getting Input from User.pptx
Unit-2 Getting Input from User.pptxUnit-2 Getting Input from User.pptx
Unit-2 Getting Input from User.pptx
 
Intravert Server side processing for Cassandra
Intravert Server side processing for CassandraIntravert Server side processing for Cassandra
Intravert Server side processing for Cassandra
 
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
NYC* 2013 - "Advanced Data Processing: Beyond Queries and Slices"
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
 
soft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.jssoft-shake.ch - Hands on Node.js
soft-shake.ch - Hands on Node.js
 
JavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your codeJavaScript Advanced - Useful methods to power up your code
JavaScript Advanced - Useful methods to power up your code
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
 
Boost delivery stream with code discipline engineering
Boost delivery stream with code discipline engineeringBoost delivery stream with code discipline engineering
Boost delivery stream with code discipline engineering
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
A miało być tak... bez wycieków
A miało być tak... bez wyciekówA miało być tak... bez wycieków
A miało być tak... bez wycieków
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Einführung in TypeScript
Einführung in TypeScriptEinführung in TypeScript
Einführung in TypeScript
 
.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#.NET Foundation, Future of .NET and C#
.NET Foundation, Future of .NET and C#
 

More from Denis Voituron

DevDay 2021 - Codez comme un ninja
DevDay 2021 - Codez comme un ninjaDevDay 2021 - Codez comme un ninja
DevDay 2021 - Codez comme un ninjaDenis Voituron
 
Azure DevOps Tests Plan
Azure DevOps Tests PlanAzure DevOps Tests Plan
Azure DevOps Tests PlanDenis Voituron
 
MIC QRS "JWT, la superstar pour sécuriser vos WebAPI"
MIC QRS "JWT, la superstar pour sécuriser vos WebAPI"MIC QRS "JWT, la superstar pour sécuriser vos WebAPI"
MIC QRS "JWT, la superstar pour sécuriser vos WebAPI"Denis Voituron
 
Azure Pipelines - Et si on arrêtait de mettre en production avec des Disquettes
Azure Pipelines - Et si on arrêtait de mettre en production avec des DisquettesAzure Pipelines - Et si on arrêtait de mettre en production avec des Disquettes
Azure Pipelines - Et si on arrêtait de mettre en production avec des DisquettesDenis Voituron
 
GitHub et Microsoft Azure DevOps - Le mariage parfait
GitHub et Microsoft Azure DevOps - Le mariage parfaitGitHub et Microsoft Azure DevOps - Le mariage parfait
GitHub et Microsoft Azure DevOps - Le mariage parfaitDenis Voituron
 
Les méthodes agiles dans TFS
Les méthodes agiles dans TFSLes méthodes agiles dans TFS
Les méthodes agiles dans TFSDenis Voituron
 
Awareness Oniryx - Mai 2018
Awareness Oniryx - Mai 2018Awareness Oniryx - Mai 2018
Awareness Oniryx - Mai 2018Denis Voituron
 
Procédures CLR pour SQL Server : avantages et inconvénients
Procédures CLR pour SQL Server : avantages et inconvénientsProcédures CLR pour SQL Server : avantages et inconvénients
Procédures CLR pour SQL Server : avantages et inconvénientsDenis Voituron
 
Microsoft Experieces 2016 - Retour d’expériences sur TFS Online
Microsoft Experieces 2016 - Retour d’expériences sur TFS OnlineMicrosoft Experieces 2016 - Retour d’expériences sur TFS Online
Microsoft Experieces 2016 - Retour d’expériences sur TFS OnlineDenis Voituron
 
Développer avec un Simple Object Mapping Toolkit pour SQL Server
Développer avec un Simple Object Mapping Toolkit pour SQL ServerDévelopper avec un Simple Object Mapping Toolkit pour SQL Server
Développer avec un Simple Object Mapping Toolkit pour SQL ServerDenis Voituron
 
Les cinq bonnes pratiques des Tests Unitaires dans un projet Agile
Les cinq bonnes pratiques des Tests Unitaires dans un projet AgileLes cinq bonnes pratiques des Tests Unitaires dans un projet Agile
Les cinq bonnes pratiques des Tests Unitaires dans un projet AgileDenis Voituron
 
DevFM #20 : SqlDatabaseCommand, un Simple Object Mapping Toolkit
DevFM #20 : SqlDatabaseCommand, un Simple Object Mapping ToolkitDevFM #20 : SqlDatabaseCommand, un Simple Object Mapping Toolkit
DevFM #20 : SqlDatabaseCommand, un Simple Object Mapping ToolkitDenis Voituron
 
Présentation et bonnes pratiques du pattern MVVM - MIC Belgique
Présentation et bonnes pratiques du pattern MVVM - MIC BelgiquePrésentation et bonnes pratiques du pattern MVVM - MIC Belgique
Présentation et bonnes pratiques du pattern MVVM - MIC BelgiqueDenis Voituron
 
Presentation MIC SummerCamp 2015 WaterStock
Presentation MIC SummerCamp 2015 WaterStockPresentation MIC SummerCamp 2015 WaterStock
Presentation MIC SummerCamp 2015 WaterStockDenis Voituron
 
Visual Studio 2015: Increase your Productivity
Visual Studio 2015: Increase your ProductivityVisual Studio 2015: Increase your Productivity
Visual Studio 2015: Increase your ProductivityDenis Voituron
 

More from Denis Voituron (20)

Go lean, Go green
Go lean, Go greenGo lean, Go green
Go lean, Go green
 
DevDay 2021 - Codez comme un ninja
DevDay 2021 - Codez comme un ninjaDevDay 2021 - Codez comme un ninja
DevDay 2021 - Codez comme un ninja
 
Azure DevOps Tests Plan
Azure DevOps Tests PlanAzure DevOps Tests Plan
Azure DevOps Tests Plan
 
MIC QRS "JWT, la superstar pour sécuriser vos WebAPI"
MIC QRS "JWT, la superstar pour sécuriser vos WebAPI"MIC QRS "JWT, la superstar pour sécuriser vos WebAPI"
MIC QRS "JWT, la superstar pour sécuriser vos WebAPI"
 
Azure Pipelines - Et si on arrêtait de mettre en production avec des Disquettes
Azure Pipelines - Et si on arrêtait de mettre en production avec des DisquettesAzure Pipelines - Et si on arrêtait de mettre en production avec des Disquettes
Azure Pipelines - Et si on arrêtait de mettre en production avec des Disquettes
 
GitHub et Microsoft Azure DevOps - Le mariage parfait
GitHub et Microsoft Azure DevOps - Le mariage parfaitGitHub et Microsoft Azure DevOps - Le mariage parfait
GitHub et Microsoft Azure DevOps - Le mariage parfait
 
Azure for Dev
Azure for DevAzure for Dev
Azure for Dev
 
DevDay 2018 - Blazor
DevDay 2018 - BlazorDevDay 2018 - Blazor
DevDay 2018 - Blazor
 
Les méthodes agiles dans TFS
Les méthodes agiles dans TFSLes méthodes agiles dans TFS
Les méthodes agiles dans TFS
 
Awareness Oniryx - Mai 2018
Awareness Oniryx - Mai 2018Awareness Oniryx - Mai 2018
Awareness Oniryx - Mai 2018
 
Le futur de .NET
Le futur de .NETLe futur de .NET
Le futur de .NET
 
Procédures CLR pour SQL Server : avantages et inconvénients
Procédures CLR pour SQL Server : avantages et inconvénientsProcédures CLR pour SQL Server : avantages et inconvénients
Procédures CLR pour SQL Server : avantages et inconvénients
 
Microsoft Experieces 2016 - Retour d’expériences sur TFS Online
Microsoft Experieces 2016 - Retour d’expériences sur TFS OnlineMicrosoft Experieces 2016 - Retour d’expériences sur TFS Online
Microsoft Experieces 2016 - Retour d’expériences sur TFS Online
 
Développer avec un Simple Object Mapping Toolkit pour SQL Server
Développer avec un Simple Object Mapping Toolkit pour SQL ServerDévelopper avec un Simple Object Mapping Toolkit pour SQL Server
Développer avec un Simple Object Mapping Toolkit pour SQL Server
 
Les cinq bonnes pratiques des Tests Unitaires dans un projet Agile
Les cinq bonnes pratiques des Tests Unitaires dans un projet AgileLes cinq bonnes pratiques des Tests Unitaires dans un projet Agile
Les cinq bonnes pratiques des Tests Unitaires dans un projet Agile
 
DevFM #20 : SqlDatabaseCommand, un Simple Object Mapping Toolkit
DevFM #20 : SqlDatabaseCommand, un Simple Object Mapping ToolkitDevFM #20 : SqlDatabaseCommand, un Simple Object Mapping Toolkit
DevFM #20 : SqlDatabaseCommand, un Simple Object Mapping Toolkit
 
Présentation et bonnes pratiques du pattern MVVM - MIC Belgique
Présentation et bonnes pratiques du pattern MVVM - MIC BelgiquePrésentation et bonnes pratiques du pattern MVVM - MIC Belgique
Présentation et bonnes pratiques du pattern MVVM - MIC Belgique
 
Presentation MIC SummerCamp 2015 WaterStock
Presentation MIC SummerCamp 2015 WaterStockPresentation MIC SummerCamp 2015 WaterStock
Presentation MIC SummerCamp 2015 WaterStock
 
Scrum Guide
Scrum GuideScrum Guide
Scrum Guide
 
Visual Studio 2015: Increase your Productivity
Visual Studio 2015: Increase your ProductivityVisual Studio 2015: Increase your Productivity
Visual Studio 2015: Increase your Productivity
 

Recently uploaded

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

A la découverte de TypeScript

  • 1. À la découverte de Denis Voituron
  • 2. Agenda • Installation • JavaScript Strongly Typed • Object Oriented Programming • Find your Data with LINQ • Asynchronous Programming • Bests Practices • Advantages and Disadvantages • Conclusion
  • 5. JavaScript Problèmes du langage • Langage interprété • Absence de modules • Typage faible • Conversions automatiques • Portée (this) • Manque de types statiques
  • 6. Programming language Superset of JavaScript Transpiled into JavaScript Open Source Developped by Microsoft, supported by Google lang.org
  • 7. «Microsoft's TypeScript may be the best of the many Javascript front ends. It seems to generate the most attractive code.» https://insights.stackoverflow.com/survey/2018
  • 8.
  • 10. Installation • Visual Studio Code : https://code.visualstudio.com • NodeJS et NPM : https://nodejs.org • TypeScript : • http-Server (Node) : npm install TypeScript -g npm install http-server -g
  • 11. Reload Window & Open TS file Specifies the folder path containing the tsserver and lib*.d.ts files to use.
  • 12. Sample function startGame() { var myMessage = document.getElementById("message"); myMessage.innerText = "Hello world"; } document.getElementById("btnStart").addEventListener("click", startGame); HelloWorld.ts <html> <body> <div id="message"></div> <button id="btnStart">Start</button> <script src="HelloWorld.js"></script> </body> </html> Index.html tsc HelloWorld.ts
  • 13. tsconfig.json • Target ECMAScript 5 • SourceMap Debugging in Chrome • Strict Object is possibly 'null’ • Watch Run ‘tsc’ and update files • … { "compilerOptions": { "target": "es5", "noImplicitAny": true, "sourceMap": true, "watch": true, "strict": true, "removeComments": true, "outDir": "./dist" }, "include": [ "./**/*.ts" ], "exclude": [ "node_modules" ] } tsconfig.json tsc --init https://html5test.com
  • 15.
  • 16. Basic Types Boolean - Number - String - Array - Enum var name: string = "Denis" var age: number = 21 var birthdate: Date; var name = "Denis"; var age = 21; var birthdate; birthdate.
  • 17. Declarations with let and const console.log(someString); var someString = "hello World"; let someString = "hello World"; console.log(someString); const someString = "hello World"; someString = "a new World";
  • 18. Type Annotations and Type Inference let x: string = "Hello World"; x = 42; let x = "Hello World"; x = 42; let name: string = "Voituron"; let message = `My name is ${name}`;
  • 19. Union Types, Null, Undefined { "compilerOptions": { "strictNullChecks": true, ... let x: string; x = null; x = undefined; let y: string | null; y = null; y = undefined; let z: string | number | null; z = null; z = "Hello"; z = 123;
  • 20. Type Assertions let value: any = 5; let fixedString: string = (<number>value).toFixed(4); console.log(fixedString) // 5.0000 let value: any = 5; let fixedString: string = (value as number).toFixed(4); console.log(fixedString) // 5.0000
  • 21.
  • 22. Demo + showSolution(HTMLElement): void + play(): void - checkSolution(): Boolean + static solution: RowOfBalls + static rows: RowOfBalls[ ] + color: Colors + isClickable: boolean + render(): HTMLImageElement + render(): HTMLElement + Red + Green + Yellow + Blue + White + balls: Ball[ ] + isClickable: boolean + goodBalls: number + render(): HTMLImageElement
  • 23. Method function getSurface(width: number): number { return width * width; } function getSurface(width): number { return width * width; } [ts] Parameter 'width' implicitly has an 'any' type.
  • 24. Overloaded Methods // Signatures function getSurface(width: number): number; function getSurface(width: number, height: number): number; // Main method function getSurface(width: number, height?: number): number { if (height == null) return width * width; else return width * height; }
  • 25. Default value function getSurface(width: number, height: number = width): number { return width * height; } getSurface(10); // 100 getSurface(10, 5); // 50
  • 26. Anonymous methods let square = (x: number) => x * x; square(2); // 4 let add = (a: number, b: number) => a + b; add(2, 3); // 5 let add = (a: number, b: number) => { return a + b };
  • 27. Static Members class WebDeveloper extends Developer { static jobDescription = "Build cool things"; static logFavoriteProtocol() { console.log("HTTPS, of course"); } writeTypeScript(): void { console.log(WebDeveloper.jobDescription); } }
  • 28. Generic "lib": [ "es6" ] let list = new Set<number>([0, 1]); list.add(2) let dico = new Map<string, number>([["k1", 0], ["k2", 1]]); dico.set("k1", 2); let array = new Array<string>(); array.push("Hello");
  • 29. Generic class Queue { private data = []; push = (item) => this.data.push(item); pop = () => this.data.shift(); } const queue = new Queue(); queue.push(0); queue.push("1"); // RUNTIME ERROR "lib": [ "es6" ]
  • 30. Generic class QueueNumber { private data = []; push = (item: number) => this.data.push(item); pop = (): number => this.data.shift(); } const queue = new QueueNumber(); queue.push(0); queue.push("1"); // COMPILATION ERROR class Queue<T> { private data = []; push = (item: T) => this.data.push(item); pop = (): T => this.data.shift(); } const queue = new Queue<number>(); queue.push(0); queue.push("1"); // COMPILATION ERROR
  • 31. Interfaces vs Classes Classes Define a new type Properties (with implementation) Methods (with implémentation) Can be instantiated Interfaces Define a new type Properties (signatures) Methods (signatures) Cannot be instantiated
  • 32. Interfaces interface Employee { name: string; title: string; } interface Manager extends Employee { department: string; numOfEmployees: number; scheduleMeeting: (topic: string) => void; } let developer: Employee = { name: "Voituron", title: "Developer" }
  • 33. Classes Module Oniryx.Myproject { class Developer { department: string; private _title : string; public get title() : string { return this._title; } public set title(value : string) { this._title = value; } public requirements(value: string): void { console.log(value); }
  • 34. Extending a class, implementing an interface class WebDeveloper extends Developer { favoriteEditor: string; writeTypeScript(): void { // Write code } } /// <reference path="Employee.ts" /> class Engineer implements Employee { name: string; title: string; }
  • 35. Constructors class Developer { public department: string; public title: string; constructor() { console.log("Creating a new developer"); } }
  • 36. Constructors class Developer { public department: string; public title: string; constructor() { console.log("Creating a new developer"); } } class WebDeveloper extends Developer { readonly favoriteEditor: string; constructor(editor: string) { super(); this.favoriteEditor = editor; } }
  • 37. Constructors class Developer { constructor(public department: string, public title: string) { console.log("Creating a new developer"); } } class WebDeveloper extends Developer { readonly favoriteEditor: string; constructor(editor: string) { super(); this.favoriteEditor = editor; } }
  • 38. Extension methods // global.d.ts interface Date { isInFuture(): boolean; } Date.prototype.isInFuture = function(): boolean { return (this != null && this.valueOf() > Date.now()); }
  • 39. Modules • CommonJS • SystemJS { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "traceResolution": true, default
  • 40. Exporting a declaration export interface Person { } class Manager { } // Not accessible outside the module import { Person } from "./Person"; let manager: Person
  • 41. Exporting a declaration export interface Person { } class Manager { } // Not accessible outside the module import * as People from "./Person"; let manager: People.Person
  • 42. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.21.0/system.js"></script> <script> SystemJS.config({ map: { jquery: 'https://code.jquery.com/jquery.js' }, packages: { '.': { defaultExtension: 'js' } } }); SystemJS.import("./MyApp.js"); </script> Module loader in browser • Module are dynamically loaded (via SystemJS).
  • 43.
  • 44. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.21.0/system.js"></script> <script> SystemJS.config({ map: { jquery: 'https://code.jquery.com/jquery.js', linqts: '/node_modules/linqts/dist/linqts.js' }, packages: { '.': { defaultExtension: 'js' } } }); SystemJS.import("./MyApp.js"); </script> Linq for TypeScript • SystemJS Loader npm install linqts https://github.com/kutyel/linq.ts
  • 45. Linq for TypeScript https://github.com/kutyel/linq.ts import { List } from "linqts" const arr = new List<number>([1, 2, 3, 4, 5]) .Where(x => x > 3) .Select(y => y * 2) .ToArray(); // > [8, 10]
  • 46. Linq for TypeScript https://github.com/kutyel/linq.ts npm install linqts import { List } from "linqts" let people = new List([ { Name: "Alice", Age: 25 }, { Name: "Bob", Age: 50 }, { Name: "Kathy", Age: 15 } ]); let alice = people.FirstOrDefault(i => i.Age > 18).Name;
  • 47. Linq for TypeScript https://github.com/kutyel/linq.ts Project Select Filter Where, Distinct Test Any, All Join Join Group GroupBy, Group Join Aggregate Count, Min, Max, Sum, Avg Partition Skip, SkipWhile, Take, TakeWhile Set Union, Intersect, Except Order OrderBy, OrderByDescending
  • 48.
  • 49. Async / Await • Promiseclass HelloWorld { public delay(ms: number): Promise<void> { return new Promise<void>((resolve) => { setTimeout(resolve, ms); }); } } A Promise is an object representing the eventual completion or failure of an asynchronous operation. "compilerOptions": { "target": "es5", "lib": [ "es6", "dom" ] },
  • 50. Async / Await • Promise • async / await class HelloWorld { public delay(ms: number): Promise<void> { return new Promise<void>((resolve) => { setTimeout(resolve, ms); }); } public async asyncAwait(): Promise<void> { document.write("Knock, knock! <br/>"); await this.delay(3000); // 3 seconds document.write("Who's there? <br/>"); } } new HelloWorld().asyncAwait(); // Start
  • 51.
  • 52. Compile and Build tsconfig.json { "version": "2.0.0", "tasks": [ { "type": "typescript", "tsconfig": "tsconfig.json", "problemMatcher": [ "$tsc“ ], "group": { "kind": "build", "isDefault": true } } ] } .vscodetasks.json { "compilerOptions": { "target": "es5", "module": "commonjs", "moduleResolution": "node", "traceResolution": true, "noImplicitAny": true, "sourceMap": true, "watch": true, "strict": true, "strictNullChecks": true, "removeComments": true, "outDir": "./dist", "lib": [ "es6", "dom" ] }, "include": [ "./**/*.ts" ], "exclude": [ "node_modules" ] }
  • 53. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.21.0/system.js"> </script> <script> SystemJS.config({ map: { jquery: 'https://code.jquery.com/jquery.js', linqts: '/node_modules/linqts/dist/linqts.js' }, packages: { '.': { defaultExtension: 'js' } } }); SystemJS.import("./MyApp.js"); </script> Module Loader
  • 54. Do's and Don'ts • General Types • Callback Types • Optional Parameters in Callbacks • Overloads and Callbacks • Function Overloads https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html
  • 55. Programming language Superset of JavaScript Transpiled into JavaScript Open Source Developped by Microsoft, supported by Google lang.org