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
730
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
110
How to Learn 3
airportyh
2
86
How to Learn 2
airportyh
0
100
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
生成AIを使ったコードレビューで定性的に品質カバー
chiilog
1
280
CSC307 Lecture 06
javiergs
PRO
0
690
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
AI時代の認知負荷との向き合い方
optfit
0
160
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
Package Management Learnings from Homebrew
mikemcquaid
0
230
「ブロックテーマでは再現できない」は本当か?
inc2734
0
1k
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.6k
CSC307 Lecture 10
javiergs
PRO
1
660
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
21
7.4k
副作用をどこに置くか問題:オブジェクト指向で整理する設計判断ツリー
koxya
1
610
AI巻き込み型コードレビューのススメ
nealle
2
1.2k
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
9
670
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
460
Why Our Code Smells
bkeepers
PRO
340
58k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
3.9k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
130
Marketing to machines
jonoalderson
1
4.6k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
290
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
310
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
200
KATA
mclloyd
PRO
34
15k
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