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
700
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
95
How to Learn 3
airportyh
2
76
How to Learn 2
airportyh
0
83
How To Learn
airportyh
7
1.3k
Test-Driven Development that Feels Great
airportyh
0
8.8k
Other Decks in Programming
See All in Programming
Fibonacci Function Gallery - Part 2
philipschwarz
PRO
0
210
生成AIでGitHubソースコード取得して仕様書を作成
shukob
0
630
PHPUnitしか使ってこなかった 一般PHPerがPestに乗り換えた実録
mashirou1234
0
420
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
1.8k
ErdMap: Thinking about a map for Rails applications
makicamel
1
600
GitHub CopilotでTypeScriptの コード生成するワザップ
starfish719
26
6k
混沌とした例外処理とエラー監視に秩序をもたらす
morihirok
13
2.2k
歴史と現在から考えるスケーラブルなソフトウェア開発のプラクティス
i10416
0
300
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
360
Flatt Security XSS Challenge 解答・解説
flatt_security
0
730
asdf-ecspresso作って 友達が増えた話 / Fujiwara Tech Conference 2025
koluku
0
1.4k
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
930
Featured
See All Featured
Faster Mobile Websites
deanohume
305
30k
BBQ
matthewcrist
85
9.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.2k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
500
Become a Pro
speakerdeck
PRO
26
5.1k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
192
16k
Building Your Own Lightsaber
phodgson
104
6.2k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
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