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
TypeScript で Optional Chaining を使ってみた
Search
Masaki Koyanagi
October 25, 2019
Programming
800
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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.3k
WebHID API でリングコン のセンサー値を取得してみた
mascii
1
1.1k
Pros and Cons で考える Vue 2 Composition API
mascii
4
1.2k
Joy-ConをJavaScriptでプレゼンリモコンにした話
mascii
0
650
Vue.jsでCSS Modulesを使ってみた
mascii
0
180
不変量
mascii
1
250
Nuxt.js+Firebaseで個人サービスを作るまで
mascii
1
2.6k
JavaScriptのバージョンの話
mascii
1
2.4k
あなたのお家に眠るラズパイを救出したい
mascii
4
3.2k
Other Decks in Programming
See All in Programming
残高管理から台帳サービスへの進化
artoy
1
200
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
Web Framework Benchmark Battle 2026, Any%
a_matsuda
2
2.5k
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.7k
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
440
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
430
Domain-Driven Transformation
hschwentner
2
2.3k
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
Featured
See All Featured
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
How to Ace a Technical Interview
jacobian
280
24k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
From π to Pie charts
rasagy
1
400
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
360
Intergalactic Javascript Robots from Outer Space
tanoku
273
28k
Ethics towards AI in product and experience design
skipperchong
2
440
Context Engineering - Making Every Token Count
addyosmani
9
1.2k
Exploring anti-patterns in Rails
aemeredith
4
540
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