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
Toby Ho
August 20, 2018
Programming
0
720
A Non-Zero Number of TypeScript Tips
An introduction to TypeScript.
Toby Ho
August 20, 2018
Tweet
Share
More Decks by Toby Ho
See All by Toby Ho
Debugging Ajax Calls
airportyh
0
100
How to Learn 3
airportyh
2
81
How to Learn 2
airportyh
0
97
How To Learn
airportyh
7
1.4k
Test-Driven Development that Feels Great
airportyh
0
8.8k
Other Decks in Programming
See All in Programming
testingを眺める
matumoto
1
130
Honoアップデート 2025年夏
yusukebe
1
910
Namespace and Its Future
tagomoris
6
690
旅行プランAIエージェント開発の裏側
ippo012
2
820
JSONataを使ってみよう Step Functionsが楽しくなる実践テクニック #devio2025
dafujii
0
270
OSS開発者という働き方
andpad
5
1.7k
CSC305 Summer Lecture 12
javiergs
PRO
0
130
Azure SRE Agentで運用は楽になるのか?
kkamegawa
0
1.3k
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
410
Ruby Parser progress report 2025
yui_knk
1
290
フロントエンドのmonorepo化と責務分離のリアーキテクト
kajitack
2
160
AIを活用し、今後に備えるための技術知識 / Basic Knowledge to Utilize AI
kishida
19
4.6k
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
358
30k
The Cult of Friendly URLs
andyhume
79
6.6k
Making the Leap to Tech Lead
cromwellryan
134
9.5k
Fireside Chat
paigeccino
39
3.6k
The Art of Programming - Codeland 2020
erikaheidi
55
13k
Git: the NoSQL Database
bkeepers
PRO
431
66k
Statistics for Hackers
jakevdp
799
220k
Building Adaptive Systems
keathley
43
2.7k
For a Future-Friendly Web
brad_frost
179
9.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
Code Reviewing Like a Champion
maltzj
525
40k
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