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
TypeScript で Optional Chaining を使ってみた
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Masaki Koyanagi
October 25, 2019
Programming
770
1
Share
TypeScript で Optional Chaining を使ってみた
WeJS @ 37th
https://wajs.connpass.com/event/150356/
Masaki Koyanagi
October 25, 2019
More Decks by Masaki Koyanagi
See All by Masaki Koyanagi
Vitestを使った型テストの始め方
mascii
6
3.2k
WebHID API でリングコン のセンサー値を取得してみた
mascii
1
1.1k
Pros and Cons で考える Vue 2 Composition API
mascii
4
1.2k
Joy-ConをJavaScriptでプレゼンリモコンにした話
mascii
0
610
Vue.jsでCSS Modulesを使ってみた
mascii
0
160
不変量
mascii
1
220
Nuxt.js+Firebaseで個人サービスを作るまで
mascii
1
2.5k
JavaScriptのバージョンの話
mascii
1
2.4k
あなたのお家に眠るラズパイを救出したい
mascii
4
3.1k
Other Decks in Programming
See All in Programming
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
28
19k
Agent Skills を社内で育てる仕組み作り
jackchuka
1
1.8k
Claude CodeでETLジョブ実行テストを自動化してみた
yoshikikasama
0
1.2k
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.7k
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
180
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
400
サークル参加から学ぶ、小さな事業の回し方
yuzneri
0
160
認証統合から始めるフロントエンドの機能単位開発 — マイクロサービス思想の適用
koukimiura
0
100
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
450
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
130
AIと共に生きる技術選定 2026
sgash708
0
130
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
770
Featured
See All Featured
Claude Code のすすめ
schroneko
67
220k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
210
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
690
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
280
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
55k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Deep Space Network (abreviated)
tonyrice
0
130
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