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
750
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
More Decks by Toby Ho
See All by Toby Ho
Debugging Ajax Calls
airportyh
0
120
How to Learn 3
airportyh
2
100
How to Learn 2
airportyh
0
110
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
Even G2とAWSで推しのエージェントを召喚しよう!
har1101
1
140
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
150
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
330
スマートグラスで並列バイブコーディング
hyshu
0
270
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
220
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
360k
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
7.1k
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
280
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
110
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.4k
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
620
Oxlintのカスタムルールの現況
syumai
6
1.2k
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Faster Mobile Websites
deanohume
310
32k
Building Adaptive Systems
keathley
44
3.1k
The Curse of the Amulet
leimatthew05
2
13k
Amusing Abliteration
ianozsvald
1
220
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
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