$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TypeScriptで幸せになろう
Search
puku0x
February 26, 2018
Technology
0
260
TypeScriptで幸せになろう
FukuokaJS #2 LT
puku0x
February 26, 2018
Tweet
Share
More Decks by puku0x
See All by puku0x
生成AIではじめるテスト駆動開発
puku0x
0
720
実践!カスタムインストラクション&スラッシュコマンド
puku0x
2
2.4k
Nx × AI によるモノレポ活用 〜コードジェネレーター編〜
puku0x
0
1.4k
ファインディにおけるフロントエンド技術選定の歴史
puku0x
2
250
ファインディでのGitHub Actions活用事例
puku0x
9
3.6k
Findyの開発生産性向上への取り組み ~Findyフロントエンドの場合~
puku0x
0
450
Findyの開発生産性を上げるためにやったこと
puku0x
1
620
Angularコーディングスタイルガイドはいいぞ
puku0x
1
400
Nx CloudでCIを爆速にした話
puku0x
0
920
Other Decks in Technology
See All in Technology
Power of Kiro : あなたの㌔はパワステ搭載ですか?
r3_yamauchi
PRO
0
200
S3を正しく理解するための内部構造の読解
nrinetcom
PRO
3
200
生成AI時代におけるグローバル戦略思考
taka_aki
0
210
MariaDB Connector/C のcaching_sha2_passwordプラグインの仕様について
boro1234
0
930
Microsoft Agent 365 についてゆっくりじっくり理解する!
skmkzyk
0
400
AIの長期記憶と短期記憶の違いについてAgentCoreを例に深掘ってみた
yakumo
4
460
AWS運用を効率化する!AWS Organizationsを軸にした一元管理の実践/nikkei-tech-talk-202512
nikkei_engineer_recruiting
0
130
Strands Agents × インタリーブ思考 で変わるAIエージェント設計 / Strands Agents x Interleaved Thinking AI Agents
takanorig
4
1.1k
Sansanが実践する Platform EngineeringとSREの協創
sansantech
PRO
2
950
Databricks向けJupyter Kernelでデータサイエンティストの開発環境をAI-Readyにする / Data+AI World Tour Tokyo After Party
genda
1
600
Connection-based OAuthから学ぶOAuth for AI Agents
flatt_security
0
110
Amazon Quick Suite で始める手軽な AI エージェント
shimy
1
980
Featured
See All Featured
WCS-LA-2024
lcolladotor
0
380
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
What's in a price? How to price your products and services
michaelherold
246
13k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
34
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
0
39
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
7.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
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Ͱ ͤʹͳΖ͏ʂ
͝ਗ਼ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠