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
genericで強力な型が付いたコンポーネントを作ろう
Search
お窓
October 22, 2024
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
genericで強力な型が付いたコンポーネントを作ろう
こちらで発表したものです。初LTでした。
https://optim.connpass.com/event/330716/
お窓
October 22, 2024
Other Decks in Programming
See All in Programming
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
270
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
610
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
Jetpack Compose Mechanisms
skydoves
3
820
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
290
ジョジョの世界をXRで再現する
mofurune
0
160
残高管理から台帳サービスへの進化
artoy
1
200
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
Optunaを作ったときにやりたかったこと、その後 (2026/10/16, Optuna Meetup #3)
iwiwi
1
430
AWSに止められる覚悟してますか?
morizo_1984
2
530
Next.js: The final boss of Web Performance
guaca
0
250
Featured
See All Featured
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
950
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
320
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.4k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
The untapped power of vector embeddings
frankvandijk
2
1.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
540
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Transcript
genericで強力な型が付いたコ ンポーネントを作ろう お窓
自己紹介 お窓 Vue3を書く3年目フロントエンドエンジニア Twitter (𝕏) @shallow_omado お仕事 ネットショップSaaS管理画面のフロントエンド開発 推し事 ご注文はうさぎですか
? の 香風智乃(かふうちの) を推します 趣味 ニコニコ動画で日常系アニメを見たり とあるゲームのAPIを開発したり 2
3 Vuetify3 の VSelect コンポーネント のラッパーに強力な型定義を付けたお話 話す内容
4 VSelectコンポーネントとは 選択肢から 1つ(または複数 )要素を選べるコンポーネント
5 VSelectコンポーネントの悲しいところ 型の絞り込みが完全じゃない 😥 Vuetify 公式サイト https://vuetifyjs.com/ja/components/selects/
6 VSelectコンポーネントを普通に使ってみる model-valueに渡したのと 同じ型がupdate:model-valueに返る
7 VSelectコンポーネントを普通に使ってみる itemsと噛み合わない型の ref値も渡せてしまう
8 VSelectコンポーネントを普通に使ってみる itemsと噛み合わない item-titleやitem-valueを渡せてしまう
9 もっと厳密な型を作りたい (既にデザインカスタマイズのために VSelectのラップコンポーネントがあるので) 型定義を上手い具合に改善できないものか ... 🤔
https://azukiazusa.dev/blog/vue-generic-component/ 10 解決策となりそうな記事 👀
https://azukiazusa.dev/blog/vue-generic-component/ 11 解決策となりそうな記事 👀
12 実際にやってみる
13 実際にやってみる
14 できたもの
15 できたもの
16 書いた感想 - ラッパーが無い環境であれば VSelectデフォルトの型でも 問題ないかも? (ドキュメント通りのanyだと勘違いしていた) - withDefaultsとの相性は悪そう 型エラーを回避する方法を模索するも見つからず断念
17 今後の展望 - VSelect以外にも VComboboxやVRadioGroup、VIcon等 のラッパーを作ると 型定義を強化できそう - genericsを大量に定義するとLinter負荷が心配 型パフォーマンスを計測する方法があれば計測したい
- VSelectは本来テキスト配列も受け取る可能性がある その型もなんとか表現したい
18 まとめ ・VSelectの items や update:modelValueの 型定義は不完全なところがある ・VSelectをラップするコンポーネントがあったので genericsを使って型定義を強化した ・型定義がビシバシ効いてRef指定ミスが起こりづらくなった✨
関連資料 - Vue.js でジェネリックコンポーネントを使う - https://azukiazusa.dev/blog/vue-generic-component/ - 【Vue3】ジェネリクスコンポーネント + Panda
CSS を使ってコンポーネントを 作成してみる - https://zenn.dev/comm_vue_nuxt/articles/2fc54416899fcb 19