Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
TypeScript で Optional Chaining を使ってみた
Search
Masaki Koyanagi
October 25, 2019
Programming
1
750
TypeScript で Optional Chaining を使ってみた
WeJS @ 37th
https://wajs.connpass.com/event/150356/
Masaki Koyanagi
October 25, 2019
Tweet
Share
More Decks by Masaki Koyanagi
See All by Masaki Koyanagi
Vitestを使った型テストの始め方
mascii
6
3.1k
WebHID API でリングコン のセンサー値を取得してみた
mascii
1
1.1k
Pros and Cons で考える Vue 2 Composition API
mascii
4
1.2k
Joy-ConをJavaScriptでプレゼンリモコンにした話
mascii
0
590
Vue.jsでCSS Modulesを使ってみた
mascii
0
140
不変量
mascii
1
200
Nuxt.js+Firebaseで個人サービスを作るまで
mascii
1
2.5k
JavaScriptのバージョンの話
mascii
1
2.3k
あなたのお家に眠るラズパイを救出したい
mascii
4
3.1k
Other Decks in Programming
See All in Programming
20 years of Symfony, what's next?
fabpot
2
360
Github Copilotのチャット履歴ビューワーを作りました~WPF、dotnet10もあるよ~ #clrh111
katsuyuzu
0
110
ゲームの物理 剛体編
fadis
0
350
チームをチームにするEM
hitode909
0
340
開発に寄りそう自動テストの実現
goyoki
2
1k
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
340
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
840
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
120
從冷知識到漏洞,你不懂的 Web,駭客懂 - Huli @ WebConf Taiwan 2025
aszx87410
2
2.7k
これならできる!個人開発のすゝめ
tinykitten
PRO
0
110
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
390
AIコーディングエージェント(NotebookLM)
kondai24
0
200
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Embracing the Ebb and Flow
colly
88
4.9k
Building Adaptive Systems
keathley
44
2.9k
Building an army of robots
kneath
306
46k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Docker and Python
trallard
47
3.7k
Automating Front-end Workflow
addyosmani
1371
200k
RailsConf 2023
tenderlove
30
1.3k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
How STYLIGHT went responsive
nonsquared
100
6k
Transcript
None
• • •
• •
None
const user1 = { age: 26, driverLicense: { expirationDate: '2023/01/22'
}, } const user2 = { age: 12, driverLicense: null, } user1.driverLicense.expirationDate // '2023/01/22' user2.driverLicense.expirationDate // TypeError: Cannot read property 'expirationDate' of null
•
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Operators/Optional_chaining
const user1 = { age: 26, driverLicense: { expirationDate: '2023/01/22'
}, } const user2 = { age: 12, driverLicense: null, } user1.driverLicense?.expirationDate // '2023/01/22' user2.driverLicense?.expirationDate // undefined
• let expirationDate if (user.driverLicense) { expirationDate = user.driverLicense.expirationDate }
None
None
• ◦ https://devblogs.microsoft.com/typescript/announcing-typescript-3-7-rc/
https://devblogs.microsoft.com/typescript/ announcing-typescript-3-7-rc/ http://www.typescriptlang.org/play/
• "use strict"; var _a, _b; const foo = {
bar: null }; // foo?.bar?.baz (_b = (_a = foo) === null || _a === void 0 ? void 0 : _a.bar) === null || _b === void 0 ? void 0 : _b.baz;
• • const foo = { items: ['Pen', 'Pineapple', 'Apple'],
get bar() { console.count('bar!'); return { baz: this.items.join() }; } } foo?.bar?.baz // bar!: 1 // 'Pen,Pineapple,Apple' foo && foo.bar && foo.bar.baz // bar!: 2 // bar!: 3 // 'Pen,Pineapple,Apple'
• • $ npm i typescript@rc ts-node $ npx ts-node
None