Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
TypeScriptで幸せになろう
Search
puku0x
February 26, 2018
Technology
290
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TypeScriptで幸せになろう
FukuokaJS #2 LT
puku0x
February 26, 2018
More Decks by puku0x
See All by puku0x
え?フロントエンドエンジニアの ワイがインフラも!?
puku0x
1
1.5k
新メンバーのために、シニアエンジニアが環境を作る時代
puku0x
0
1.6k
Agent Skills 入門
puku0x
0
2.2k
ファインディにおけるフロントエンド技術選定の歴史
puku0x
2
2.3k
生成AIではじめるテスト駆動開発
puku0x
0
1.5k
実践!カスタムインストラクション&スラッシュコマンド
puku0x
2
3.4k
Nx × AI によるモノレポ活用 〜コードジェネレーター編〜
puku0x
0
1.7k
ファインディにおけるフロントエンド技術選定の歴史
puku0x
2
330
ファインディでのGitHub Actions活用事例
puku0x
9
4k
Other Decks in Technology
See All in Technology
絵ではじめるKubernetesセキュリティ
aoi1
3
560
Snowflakeのコスト最適化を支えるアーキテクチャ設計
ktatsuya
1
1.6k
AI de Idea
kawaguti
PRO
2
110
Issue 駆動でスペシャリストの意図を届ける、AI 実装のアクセシビリティ向上
thkt
0
110
omasushiというライブラリを作った
polidog
PRO
0
230
「守り」で活用するオンデバイスLLM 〜写ってはいけないを総力戦で防ぐ〜 / iOSDC Japan 2026
nakamuuu
0
160
What the customer really needed
kawaguti
PRO
2
170
登壇の自信を奪う3匹のオバケ / 3 Ghosts That Rob You of Your Confidence in Public Speaking
pauli
8
920
30座EKS, 180次升級淬煉的EKS Upgrade Skill 的歷程
eric8230
0
160
Reactの設計論
uhyo
24
13k
Claude in Chrome 入門 / Introduction to Claude in Chrome
cielo1985
0
810
LLMに渡さなかった仕事
nanaism
0
170
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Tell your own story through comics
letsgokoyo
1
1.1k
Balancing Empowerment & Direction
lara
6
1.3k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Automating Front-end Workflow
addyosmani
1369
210k
Darren the Foodie - Storyboard
khoart
PRO
4
3.9k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.1k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Building the Perfect Custom Keyboard
takai
2
870
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.9k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
850
Transcript
TypeScriptͰͤʹͳΖ͏ FukuokaJS #2 2018/02/23
(ג)Ϩεί ΤϯδχΞ ng-fukuokaද ৽ٓါ !QVLVY
JavaScriptॻ͍ͯ·͔͢ʁ
var a = 1; a = a + ‘1’; console.log(a
/ 2); // 5.5
None
ʮܕʯཉ͍͠ʂ
None
TypeScript • MSͷAltJS • ੩తܕ͚ + ES201xͷߏจ ES6 TS ES5
੩తܕ͚ • ม • ؔ text: string function value(): number
let a: number; a = 100; // OK a = ‘100’; // Error !! ίϯύΠϧ࣌ ʹఆ
ϓϦϛςΟϒܕ • จࣈྻʢstringʣ • ʢnumberʣ • ਅِʢbooleanʣ nullͱ͔undefinedͱ͔͋Δ
Anyܕ • ैདྷͷJSͰͬͯͨͭ • ઃఆͰېࢭ͢Δ͜ͱग़དྷΔ value: any
AnyܕԿͰ͋ΓͳͷͰ ཚ༻͠ͳ͍ͰͶ
TypeScriptͰ ͤʹͳΖ͏
classॻ͍ͯ·͔͢ʁ
Ϋϥε • ES2017൛ class Person { constructor(name) { this.name =
name; } } Ҿ૿͑Δͱ Կॻ͘ͷ໘…
ίϯετϥΫλ ؆୯ʹॻ͖͍ͨ
Ϋϥε • TypeScript൛ class Person { constructor(public name?: string) {}
} ͋Γ͕ͱ͏ΞΫηεम০ࢠʂ ʢͱΦϓγϣφϧʣ
ΦϒδΣΫτͷೖ
ΦϒδΣΫτͷೖ • ES2017൛ let person = new Person(); person =
{ name: ‘ςετଠ’, gender: ‘MALE’, // উखʹՃ }; มͳΦϒδΣΫτ ೖͬͨΓ͠ͳ͍͔ͳ…
ಛఆͷΦϒδΣΫτ ͷΈೖ͍ͤͨ͞
ΦϒδΣΫτͷೖ • TypeScript൛ ͪΌΜͱ͍ͯ͘ΕΔʂ let person = new Person(); person
= {ɹ name: ‘ςετଠ’, gender: ‘MALE’, // Error };
ΦϒδΣΫτͷೖ • ΠϯλʔϑΣʔεΛͬͨ߹ interface IPerson { name: string; } const
person: IPerson = {ɹ name: ‘ςετଠ’, gender: ‘MALE’, // Error }; ͋Γ͕ͱ͏ΠϯλʔϑΣʔεʂ
ͷೖ
ͷೖ • ES2017൛ class Person { gender; // ‘MALE’ or
‘FEMALE’ } มͳ͕ ೖͬͨΓ͠ͳ͍͔ͳ…
ಛఆͷͷΈ ೖ͍ͤͨ͞
ͷೖ • TypeScript൛ class Person { gender: ‘MALE’ | ‘FEMALE’;
} ͋Γ͕ͱ͏ڞ༻ܕʂ EnumͰ͍͍Αʂ
Union Typeʢڞ༻ܕʣ • Ϧςϥϧ • จࣈྻϦςϥϧ type Grade = 1
| 2 | 3 | 4 | 5; type Gender = ‘MALE’ | ‘FEMALE’;
ʮܕʯ͍͍ͬͯΑͶ
TypeScript ͡ΊͯΈ·ͤΜ͔ʁ
ڥͷ༻ҙ $ npm install -g typescript $ tsc -—init $
tsc —-watch • ίϯύΠϥͷΠϯετʔϧ
ओཁFWTSରԠ • Angularʢඪ४ʣ • ReactʢTSXʣ • Vue.jsʢv2.5ʙʣ
IUUQTBOHVMBSKQ AngularΑΖ͘͠Ͷʂ
TypeScriptͰ ͤʹͳΖ͏ʂ
͝ਗ਼ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠