Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
84
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
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
120
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
390
手が足りない!兼業データエンジニアに必要だったアーキテクチャと立ち回り
zinkosuke
0
690
配送計画の均等化機能を提供する取り組みについて(⽩⾦鉱業 Meetup Vol.21@六本⽊(数理最適化編))
izu_nori
0
150
認証・認可の基本を学ぼう後編
kouyuume
0
190
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
9
1.2k
これだけで丸わかり!LangChain v1.0 アップデートまとめ
os1ma
6
1.8k
著者と進める!『AIと個人開発したくなったらまずCursorで要件定義だ!』
yasunacoffee
0
140
Building AI Agents with TypeScript #TSKaigiHokuriku
izumin5210
6
1.3k
複数人でのCLI/Infrastructure as Codeの暮らしを良くする
shmokmt
5
2.3k
愛される翻訳の秘訣
kishikawakatsumi
3
320
エディターってAIで操作できるんだぜ
kis9a
0
730
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
5.7k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Mobile First: as difficult as doing things right
swwweet
225
10k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
70k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.7k
Into the Great Unknown - MozCon
thekraken
40
2.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.6k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The Pragmatic Product Professional
lauravandoore
37
7.1k
Producing Creativity
orderedlist
PRO
348
40k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Site-Speed That Sticks
csswizardry
13
1k
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