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
A Non-Zero Number of TypeScript Tips
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Toby Ho
August 20, 2018
Programming
750
0
Share
A Non-Zero Number of TypeScript Tips
An introduction to TypeScript.
Toby Ho
August 20, 2018
More Decks by Toby Ho
See All by Toby Ho
Debugging Ajax Calls
airportyh
0
120
How to Learn 3
airportyh
2
100
How to Learn 2
airportyh
0
110
How To Learn
airportyh
7
1.5k
Test-Driven Development that Feels Great
airportyh
0
8.8k
Other Decks in Programming
See All in Programming
JavaDoc 再入門
nagise
0
240
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.4k
サーバーレスで作る、動画データ管理基盤
oyasumipants
0
330
Oxcを導入して開発体験が向上した話
yug1224
4
270
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
120
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
1
220
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
210
dRuby over BLE
makicamel
1
260
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
140
Inspired By RubyKaigi (EN)
atzzcokek
0
490
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
2
140
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
110
Featured
See All Featured
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
210
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Into the Great Unknown - MozCon
thekraken
41
2.5k
First, design no harm
axbom
PRO
2
1.2k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Writing Fast Ruby
sferik
630
63k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
120
Designing for humans not robots
tammielis
254
26k
Why Our Code Smells
bkeepers
PRO
340
58k
Transcript
A non-zero number of TypeScript Tips
Agenda • What and why • Interfaces • Optional Properties
• Class • Generic functions / methods • Strict Null Checks • VS Code Shortcuts
What is TypeScript?
What is TypeScript • Super set of JavaScript / EcmaScript
• EcmaScript Future Proof
Why TypeScript?
Type Definitions
Interfaces the shape of an object
Interface
Interface
Interface
Interface
Implementing an Interface with a Class
Class Constructor Shorthand Equivalent shorthand to previous slide
Interface Extension
Optional Properties
None
None
Optional Properties This property is optional
Type assertion (or casting)
Type assertion (or casting) Don’t do this!!!
TypeScript Static type checking with loopholes.
Interface with Methods
Implementing an Interface with Methods
Generic Functions
Put a number in a list
Put a string in a list
Generic a thing in a list
Generic Function/Methods
Generic Function/Methods TypeScript knows!!!
Generic Types
Parameterized Types (generics) T is a type parameter
Parameterized Types
Parameterized Type: Promises
Promises Uses the fetch API
Promises
Promises Uses the fetch API
Generic Function with Generic Type!!!
Generic getItems
Generic getItems But what is articles? What is T?
Generic getItems
Generic getItems Define T explicitly
Generic getItems Or define related type and let TS infer
what T is
Generic getItems T is inferred to be IArticle based on
this related type declaration
Generic getItems
Strict Null Checks
Strict Null Checks This property is optional
Strict Null Checks tsconfig.json
Strict Null Checks
Strict Null Checks
Strict Null Checks
VS Code Help
VSCode Auto Import Helper
VSCode Auto Import Helper Click that!!!
VSCode Auto Import Helper
VSCode: Looking up type definitions Mac: Command+click Windows: Control+click Mac:
Command+hover Windows: Control+hover Popup: Drilldown:
Popup
Drilldown
Summary • What and why • Interfaces • Optional Properties
• Class • Generic functions / methods • Strict Null Checks • VS Code Shortcuts