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
TypeScriptで幸せになろう
Search
puku0x
February 26, 2018
Technology
0
240
TypeScriptで幸せになろう
FukuokaJS #2 LT
puku0x
February 26, 2018
Tweet
Share
More Decks by puku0x
See All by puku0x
ファインディにおけるフロントエンド技術選定の歴史
puku0x
2
170
ファインディでのGitHub Actions活用事例
puku0x
9
3k
Findyの開発生産性向上への取り組み ~Findyフロントエンドの場合~
puku0x
0
410
Findyの開発生産性を上げるためにやったこと
puku0x
1
560
Angularコーディングスタイルガイドはいいぞ
puku0x
1
270
Nx CloudでCIを爆速にした話
puku0x
0
770
Findyのフロントエンド設計刷新を通して得られた技術的負債との向き合い方
puku0x
1
1.7k
最高の開発体験を目指して 〜Findyのフロントエンド設計刷新〜
puku0x
0
790
VSCode GraphQL + GraphQL Code Generator による快適なフロントエンド開発
puku0x
0
2.6k
Other Decks in Technology
See All in Technology
株式会社Awarefy(アウェアファイ)会社説明資料 / Awarefy-Company-Deck
awarefy
3
11k
エンジニア主導の企画立案を可能にする組織とは?
recruitengineers
PRO
1
220
【内製開発Summit 2025】イオンスマートテクノロジーの内製化組織の作り方/In-house-development-summit-AST
aeonpeople
2
950
クラウド食堂とは?
hiyanger
0
120
JavaにおけるNull非許容性
skrb
2
2.7k
Pwned Labsのすゝめ
ken5scal
2
460
スキルだけでは満たせない、 “組織全体に”なじむオンボーディング/Onboarding that fits “throughout the organization” and cannot be satisfied by skills alone
bitkey
0
190
AI自体のOps 〜LLMアプリの運用、AWSサービスとOSSの使い分け〜
minorun365
PRO
7
450
DeepSeekとは?何がいいの? - Databricksと学ぶDeepSeek! 〜これからのLLMに備えよ!〜
taka_aki
1
110
技術スタックだけじゃない、業務ドメイン知識のオンボーディングも同じくらいの量が必要な話
niftycorp
PRO
0
110
What's new in Go 1.24?
ciarana
1
110
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
19k
Featured
See All Featured
Building an army of robots
kneath
303
45k
Six Lessons from altMBA
skipperchong
27
3.6k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
4
380
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
10
1.3k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
27
1.9k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
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Ͱ ͤʹͳΖ͏ʂ
͝ਗ਼ௌ ͋Γ͕ͱ͏͍͟͝·ͨ͠