Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
A Non-Zero Number of TypeScript Tips
Search
Toby Ho
August 20, 2018
Programming
760
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
A Non-Zero Number of TypeScript Tips
An introduction to TypeScript.
Toby Ho
August 20, 2018
Transcript
58 slides
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
More Decks by Toby Ho
See All by Toby Ho
Debugging Ajax Calls
airportyh
0
130
How to Learn 3
airportyh
2
120
How to Learn 2
airportyh
0
120
How To Learn
airportyh
7
1.6k
Test-Driven Development that Feels Great
airportyh
0
8.9k
Other Decks in Programming
See All in Programming
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
2
160
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
5.9k
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
620
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
150
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
170
なぜ私たちは「現時点では」KMPの導入を見送ったのか
chigichan24
0
190
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
330
LLM 101
dalinaum
0
490
Getting Started with Vibe Coding
miccheng
0
220
地方こそサーバーレス — 10年続けた、顔が見えるチームで確かな基盤を / Serverless Matters Most in Regional Areas — 10 Years of Building Reliable Foundations with Close-Knit Teams
seike460
PRO
1
450
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
310
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
We Have a Design System, Now What?
morganepeng
55
8.4k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
990
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
480
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
570
A better future with KSS
kneath
240
18k
The Spectacular Lies of Maps
axbom
PRO
1
1.1k