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
740
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
95
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
Spec Driven Development | AI Summit Vilnius
danielsogl
PRO
1
120
ルールルルルルRubyの中身の予備知識 ── RubyKaigiの前に予習しなイカ?
ydah
1
220
VueエンジニアがReactを触って感じた_設計の違い
koukimiura
0
190
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
430
(Re)make Regexp in Ruby: Democratizing internals for the JIT
makenowjust
3
820
ふりがな Deep Dive try! Swift Tokyo 2026
watura
0
250
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
1k
PCOVから学ぶコードカバレッジ #phpcon_odawara
o0h
PRO
0
280
AIを導入する前にやるべきこと
negima
2
290
GNU Makeの使い方 / How to use GNU Make
kaityo256
PRO
16
5.6k
【26新卒研修資料】TDD実装演習
dip_tech
PRO
0
110
Don't Prompt Harder, Structure Better
kitasuke
0
790
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.1k
Writing Fast Ruby
sferik
630
63k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
170
Navigating Team Friction
lara
192
16k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
180
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
GraphQLとの向き合い方2022年版
quramy
50
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