Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Warum TypeScript?
Search
Joshy Cyriac
September 18, 2015
Programming
0
150
Warum TypeScript?
Talk given at bed-con.org in Berlin 2015
Joshy Cyriac
September 18, 2015
Tweet
Share
Other Decks in Programming
See All in Programming
半自動E2Eで手っ取り早くリグレッションテストを効率化しよう
beryu
1
290
testingを眺める
matumoto
1
140
Updates on MLS on Ruby (and maybe more)
sylph01
1
190
アルテニア コンサル/ITエンジニア向け 採用ピッチ資料
altenir
0
110
Improving my own Ruby thereafter
sisshiki1969
1
160
基礎から学ぶ大画面対応(Learning Large-Screen Support from the Ground Up)
tomoya0x00
0
6.5k
複雑なドメインに挑む.pdf
yukisakai1225
5
1.2k
AIを活用し、今後に備えるための技術知識 / Basic Knowledge to Utilize AI
kishida
22
5.9k
「待たせ上手」なスケルトンスクリーン、 そのUXの裏側
teamlab
PRO
0
610
Refinementsのメソッド定義を4000倍速くした話
alpacatc
0
110
はじめてのMaterial3 Expressive
ym223
2
950
さようなら Date。 ようこそTemporal! 3年間先行利用して得られた知見の共有
8beeeaaat
3
1.5k
Featured
See All Featured
Making Projects Easy
brettharned
117
6.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
590
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.7k
Statistics for Hackers
jakevdp
799
220k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
Being A Developer After 40
akosma
90
590k
Practical Orchestrator
shlominoach
190
11k
Raft: Consensus for Rubyists
vanstee
140
7.1k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Transcript
WARUM TYPESCRIPT? JOSHY CYRIAC @IRRWITZ FINEBRAIN.COM
UMFRAGE
ANFANG Java-Land JS-Land
TYPESCRIPT LÖSUNGEN FÜR 2 JS PROBLEME
PROBLEM EINS
module.exports = function extract(data, topic) { … } “article.js”
var article=require(‘article’); var item = require(‘item’); article.extract(data, ‘news’); item.extract(data, 12);
PROBLEM ZWEI
function extract( data, topic ) { … }
None
–from typescriptlang.org “Any browser. Any host. Any OS. Open Source.”
JS TS TS is a TYPED superset of JS
TS Files TS Compiler JS Files
PROBLEM EINS
module.exports = function extract(data, topic) { … } “article.js”
OPTIONAL TYPE SYSTEM
var answer: number = 4; var n: number[] = [1,
2, 3]; var city: string = “Berlin”; enum Color { Red, Green, Blue }; “basic.ts”
var answer = 4; var n = [1, 2, 3];
var city = “Berlin”; var Color; (function (Color) { … } “basic.js”
var foo: any; var foos: any[]; function log(msg): void {
… } var fAdd: (x: number, y: number)=>number; “func.ts”
var foo; var foos; function log(msg) { … } var
fAdd; “func.js”
FIND REFERENCE src/services/extractor.ts function extract(data: Article[], topic: string) src/services/storer.ts ArticleExtractor.extract(data,
defaultTopic)
PROBLEM ZWEI
function extract( data, topic ) { … }
INTERFACES
interface Article { _id: string; url: string; date?: Date; title:
string; text: string; }
function extract( data: Article[], topic: string) { … }
extract(articles, “bar”);“ ✔ extract(“foo”, “bar”); ✗ Argument of type “string”
is not assignable to parameter of type Article[] ^^^^^
MORE STUFF
Type Inference Classes Modules Default parameters Optional parameters Generics Union
Types Intersection Types
INTEGRATING 3RD PARTY LIBS / FRAMEWORKS
DefinitelyTyped
EDITOR SUPPORT
None
MIGRATION
> npm install -g typescript > mv *.js *.ts >
tsc -w -m commonjs server.ts
SUMMARY
PRO CONTRA Optional TYPE SYSTEM Compiles to plain JS Compile
Step ES5/(ES6) compatible
LINKS typescriptlang.org http://basarat.gitbooks.io/typescript/