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
Unknownのことをちゃんと知りたい_関西フロントエンド忘年会
[email protected]
×...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
is_ryo
December 06, 2024
Technology
51
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Unknownのことをちゃんと知りたい_関西フロントエンド忘年会
[email protected]
× KINTOテクノロジーズ
is_ryo
December 06, 2024
More Decks by is_ryo
See All by is_ryo
生成AIとエンジニアの仕事と私~実践知を添えて~
is_ryo
0
130
tRPC入門
is_ryo
1
350
TypeScriptでWebAssemblyに入門しよう
is_ryo
0
400
Honoが良さそう🔥
is_ryo
1
1.4k
LambdaのNodejsをアップデートしたら困った話
is_ryo
2
1.4k
頑張らないオレオレVuex規約を作った話
is_ryo
4
2.9k
AppSyncで始めるGraphQL
is_ryo
1
660
Other Decks in Technology
See All in Technology
Snowflakeで実現する全社横断の顧客の声(VOC)分析・活用基盤@Snowflake World Tour Tokyo 2026
yuto16
0
160
Tab5をRubyで動くパソコンにする
kishima
2
310
【視聴者参加型!】AWSセキュリティアンチパターンクイズ
syoshie
1
490
[2026-09-11]SREは誰のもの?運用エンジニアが始める 「SRE領域への越境」とチームの進化の軌跡 〜Road to NEXT CRE
tosite
0
120
薬剤師(ドメインエキスパート)と一緒に育てる薬局向けAIアシスタント
kakehashi
PRO
2
140
Amazon Quick on DesktopがIAM Identity Centerで動かない理由
yukiogawa
0
160
スクラムで身についていた動き方を、XPで捉え直してみた
codmoninc
PRO
1
350
#jawssonic2026 あの時代が悪かった ~動かなかったSageMakerと共に迎えたイベント当日~
ktkn1129
0
140
目の前の楽しいが人生を変える - コミュニティの螺旋の歩き方と楽しむコツ / change your life
soudai
PRO
4
380
OpenTelemetry eBPF Instrumentationの舞台裏 / Behind the Scenes of OpenTelemetry eBPF Instrumentation
ymotongpoo
3
970
Sigmaで作る業務アプリ
kazushiro_honma
0
110
深夜のクラウド懺悔室 1:29:300 or 1:0:0
kazzpapa3
1
230
Featured
See All Featured
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
440
Done Done
chrislema
186
16k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
11
1k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
500
So, you think you're a good person
axbom
PRO
2
2.1k
Agile that works and the tools we love
rasmusluckow
331
22k
Mind Mapping
helmedeiros
1
350
Tell your own story through comics
letsgokoyo
1
1.1k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
240
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Transcript
Unknownのことをちゃんと 知りたい 関西フロントエンド忘年会
[email protected]
× KINTOテクノロジーズ_2024/12/06
いずりょー #EngineeringManager #TypeScriptが好き #JavaScriptは嫌い #最近は生成 AIと戯れている #kansai.ts Organizer X →
@is_ryo Bluesky → is-ryo
今日は Unknownのことちゃんと 理解して使ってる? という話をします
質問 unknown型を 意識して使っている人
終 制作・著作 ━━━━━ いずりょー
結論 ちゃんとUnknownのことを理 解できたら anyはいらない (多分…きっと…知らんけど )
サバイバル TypeScriptによると • TypeScriptのunknown型は、型が何かわからないときに使う型です • unknown型にはどのような値も代入できます • unknown型はよく「型安全なany型」と言われ、any型と対比されます • any型はどのような型の変数にも代入できますが、unknown型の値は具
体的な型へ代入できません • などと書いてある
unknown型にはどのような値も代入できる
unknown型は「型安全な any型」
unknown型とany型の違い • unknown型もany型もどのような値も代入できる • unknown型はunknown型にしか再代入できない • any型に代入したオブジェクトのプロパティ、メソッドは使用することができ るが、unknown型は使用できないし実行もできない ◦ 意図しない実行時エラーを検知することができる
ざっくり言うと unknown型は安全に型を ぶっ飛ばして any型はTSを捨てる という感じ
any型を使っていいのは TSを捨てる覚悟のあるやつだけだ …
unknown型の使い方 • any型の値をより安全にする • 型アサーションの制約を回避する • TypeGuardを利用して正しい型をつける
None
None
まとめ • とりあえず「型が何かわからない 」という時に any型 を使うのではなくて unkonwn型 を使うことで堅牢なコードに1歩近づく • その結果コード量は増えるケースが多いとは思うので、そこはいい塩梅を
探す必要がある • (個人的には) 多少コード量が多くなっても any型 がない世界を目指した い ◦ コードレビューで any型 を排除する活動をし始めている
結論 ちゃんとUnknownのことを理 解できたら anyはいらない (多分…きっと…知らんけど )
Thanks!!!