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
interface を活用して安全性と拡張性を兼ね備えた型を作る
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
all-user
November 26, 2024
Programming
0
130
interface を活用して安全性と拡張性を兼ね備えた型を作る
2024/11/16 TSKaigi KansaiのLTで使用した資料です!
https://kansai.tskaigi.org/talks/all-user
all-user
November 26, 2024
Tweet
Share
Other Decks in Programming
See All in Programming
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
440
プロダクトオーナーから見たSOC2 _SOC2ゆるミートアップ#2
kekekenta
0
230
360° Signals in Angular: Signal Forms with SignalStore & Resources @ngLondon 01/2026
manfredsteyer
PRO
0
140
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
180
AIフル活用時代だからこそ学んでおきたい働き方の心得
shinoyu
0
140
Apache Iceberg V3 and migration to V3
tomtanaka
0
180
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
21
7.4k
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
210
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
1k
AI & Enginnering
codelynx
0
120
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
470
ノイジーネイバー問題を解決する 公平なキューイング
occhi
0
110
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.4k
How STYLIGHT went responsive
nonsquared
100
6k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
230
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
590
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
750
The Cost Of JavaScript in 2023
addyosmani
55
9.5k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
440
Mobile First: as difficult as doing things right
swwweet
225
10k
Into the Great Unknown - MozCon
thekraken
40
2.3k
Transcript
© Techtouch, Inc. JOUFSGBDFΛ׆༻ͯ͠ ҆શੑͱ֦ுੑΛ݉Ͷඋ͑ͨܕΛ࡞Δ 2024/11/16 Ԭຊ ܓଠ@all-user
© Techtouch, Inc. ࣗݾհ 2 ຊ໊ɿԬຊܓଠ (JU)VCɿ!BMMVTFS 5XJUUFSɿ!BMM@@VTFS wςοΫλονגࣜձࣾͰ%0.पΓͷ։ൃΛߦ͏ &MFNFOUνʔϜͷϑϩϯτΤϯυ
wिۙ͘ͷߴඌࢁʹΑ͘ొͬͯ·͢ wӡ͕͍͍ͱ࢜ࢁ͕ݟ͑·͢
© Techtouch, Inc. 3 ΫϩευϝΠϯJGSBNFؒͷϝοηʔδϯάػೳͷ࣮Λ௨ͯ͡ɺ JOUFSGBDFͷએݴϚʔδΛ׆༻ͨ͠ࣄྫΛ͝հ͠·͢
© Techtouch, Inc. 4 ςοΫλονը໘্ʹૢ࡞ΨΠυπʔϧνοϓΛ ؆୯ʹஔ͢Δ͜ͱ͕Ͱ͖ΔϊʔίʔυπʔϧͰ͢
© Techtouch, Inc. 5 ܦඅਃͳͲͨ·ʹ͔͠Θͳ͍γεςϜͷ͍ํ͕ ͔Βͳ͍ɺɺɺͱ͍͏ܦݧΛ͞Εͨ͜ͱ Ұ͋ΔͷͰͳ͍Ͱ͠ΐ͏͔ʁ
© Techtouch, Inc. 6 ͦΜͳ࣌ʹ͜ͷΑ͏ͳऍ͕͋Ε ໎͏͜ͱͳ͘γεςϜΛར༻Ͱ͖·͢ ۭ͜͜ཝͰ0,ʂ ͔Βͳ͍࣌ ʮ99ʯΛબ
© Techtouch, Inc. 7 ΫϩευϝΠϯJGSBNFʹରԠ͍ͯ͠·͢ɻ ʢҰ෦ະରԠ͋Γʣ ۭ͜͜ཝͰ0,ʂ ͔Βͳ͍࣌ ʮ99ʯΛબ
© Techtouch, Inc. 8 ΫϩευϝΠϯJGSBNFͷ෦ʹ XJOEPX͔Β+4ͰΞΫηε͢Δ͜ͱ͕Ͱ͖ͳ͍ʂ
© Techtouch, Inc. 9 ϝοηʔδϯά͠·͢
© Techtouch, Inc. 10 ΫϩευϝΠϯJGSBNFͱͷ௨৴ػೳΛ ϥΠϒϥϦͱ࣮ͯ͢͠Δ
© Techtouch, Inc. 11 ϝοηʔδͷܕΛͲͷΑ͏ʹදݱ͢Δ͔ // ϥΠϒϥϦଆ: @tt/messaging export type
Message = { type: string; // ܕ҆શੑ͕ࣦΘΕΔ payload: any; // ܕ҆શੑ͕ࣦΘΕΔ }; const createMessaging = () => { return { postMessage(type: string, payload: any) { // ࣮ }, }; };
© Techtouch, Inc. 12 ۩ମతͳ༻్ΞϓϦέʔγϣϯଆ͔͠Βͳ͍ͷͰ େ·͔ͳܕ͔͠ఆٛ͢Δ͜ͱ͕Ͱ͖ͳ͍ɻ // ϥΠϒϥϦଆ: @tt/messaging export
type Message = { type: string; // ܕ҆શੑ͕ࣦΘΕΔ payload: any; // ܕ҆શੑ͕ࣦΘΕΔ }; const createMessaging = () => { return { postMessage(type: string, payload: any) { // ࣮ }, }; };
© Techtouch, Inc. 13 // ϥΠϒϥϦଆ: @tt/messaging export type Message
= | { type: "scrollTo"; payload: { x: number; y: number; }; } | { type: "dispatchInput"; payload: { value: string; }; } const createMessaging = () => { return { send<Msg extends Message>(type: Msg["type"], payload: Msg["payload"]) { // ࣮ }, }; }; ͡Ό͋ϥΠϒϥϦଆʹશ෦ॻ͍ͪΌ͓͏
© Techtouch, Inc. 14 // ϥΠϒϥϦଆ: @tt/messaging export type Message
= | { type: "scrollTo"; payload: { x: number; y: number; }; } | { type: "dispatchInput"; payload: { value: string; }; } | { type: "getBoundingClientRect"; payload: { selector: string; }; }; const createMessaging = () => { return { send<Msg extends Message>(type: Msg["type"], payload: Msg["payload"]) { // ࣮ }, }; }; ΞϓϦέʔγϣϯଆͰͷ༻్͕૿͑Δͨͼʹ ϥΠϒϥϦଆʹखΛՃ͑Δඞཁ͕͋Δ
© Techtouch, Inc. 15 // ϥΠϒϥϦଆ: @tt/messaging export type Message
= | { type: "scrollTo"; payload: { x: number; y: number; }; } | { type: "dispatchInput"; payload: { value: string; }; } | { type: "getBoundingClientRect"; payload: { selector: string; }; }; const createMessaging = () => { return { send<Msg extends Message>(type: Msg["type"], payload: Msg["payload"]) { // ࣮ }, }; }; ผͷΞϓϦέʔγϣϯͰར༻͢Δͱ͍ͬͨ ࠶ར༻ੑ٘ਜ਼ʹͳͬͯ͠·͏
© Techtouch, Inc. 16 ܕ҆શੑͱ֦ுੑͷͲͪΒ͔Λ ఘΊΔ͜ͱʹͳͬͯ͠·͏ɻɻɻ
© Techtouch, Inc. 17 Ͳ͏ʹ্͔ख͍͜ͱͰ͖ͳ͍͔ɺɺɺ
© Techtouch, Inc. 18 ͦ͏͍͑.6*ͷ 5IFNJOHͬͯJOUFSGBDFΛͬͯͨͳ
© Techtouch, Inc. 19 declare module '@mui/material/styles' { interface Theme
{ status: { danger: string; }; } // allow configuration using `createTheme()` interface ThemeOptions { status?: { danger?: string; }; } } 5IFNF5IFNF0QUJPOTͷܕΛ ͋ͱ͔Β֦ுͰ͖Δ
© Techtouch, Inc. 20 ͜ΕΛ͍ͬͯ͘ʂ
© Techtouch, Inc. 21 // ϥΠϒϥϦଆ: @tt/messaging export interface MessageMap
{ // ϥΠϒϥϦଆͰԿఆٛ͠ͳ͍ } const createMessaging = () => { return { send<T extends keyof MessageMap>(type: T, payload: MessageMap[T]) { // ࣮ }, }; }; ϥΠϒϥϦଆͰඞཁ࠷ݶͷఆٛͷΈ
© Techtouch, Inc. 22 // ϥΠϒϥϦଆ: @tt/messaging export interface MessageMap
{ // ϥΠϒϥϦଆͰԿఆٛ͠ͳ͍ } const createMessaging = () => { return { send<T extends keyof MessageMap>(type: T, payload: MessageMap[T]) { // ࣮ }, }; }; // ΞϓϦέʔγϣϯଆ: app.ts declare module "@tt/messaging" { interface MessageMap { scrollTo: { x: number; y: number; }; } } const messaging = createMessaging(); messaging.send("scrollTo", { x: 10, y: 42, }); // ✅ ܕ҆શ ΞϓϦέʔγϣϯଆͰ ༻్ʹԠͨ͡ϝοηʔδͷܕΛఆٛ ϥΠϒϥϦଆͰඞཁ࠷ݶͷఆٛͷΈ
© Techtouch, Inc. 23 JOUFSGBDFͷએݴԿͰখ͚ʹߦ͏͜ͱ͕Ͱ͖Δ
© Techtouch, Inc. 24 ΞϓϦέʔγϣϯଆͰ͜ΕΒͷએݴΛ ҰՕॴʹ·ͱΊͯهड़͢Δඞཁͳ͍ declare module "@tt/messaging" {
interface MessageMap { scrollTo: { x: number; y: number; }; } interface MessageMap { dispatchInput: { value: string; }; } interface MessageMap { getBoundingClientRect: { selector: string; }; } }
© Techtouch, Inc. 25 ͦͷͨΊɺΞϓϦέʔγϣϯଆͰ͜ΕΒͷએݴΛ ҰՕॴʹ·ͱΊͯهड़͢Δඞཁͳ͍ declare module "@tt/messaging" {
interface MessageMap { scrollTo: { x: number; y: number; }; } } declare module "@tt/messaging" { interface MessageMap { dispatchInput: { value: string; }; } } declare module "@tt/messaging" { interface MessageMap { getBoundingClientRect: { selector: string; }; } }
© Techtouch, Inc. 26 ؔ࿈͢Δ࣮ͷ͙ۙ͘͢Ͱએݴ ϘτϜΞοϓʹܕΛఆٛ declare module "@tt/messaging" {
interface MessageMap { scrollTo: { x: number; y: number; }; } } declare module "@tt/messaging" { interface MessageMap { dispatchInput: { value: string; }; } } declare module "@tt/messaging" { interface MessageMap { getBoundingClientRect: { selector: string; }; } }
© Techtouch, Inc. 27 // ΞϓϦέʔγϣϯଆ: iframeScript.ts import { scrollTo
} from "./PATH_TO/scrollTo.ts"; import { dispatchInput } from "./PATH_TO/dispatchInput.ts"; import { getBoundingClientRect } from "./PATH_TO/getBoundingClientRect.ts"; export const iframeImplements = { scrollTo, dispatchInput, getBoundingClientRect, } satisfies Record<keyof MessageMap, unknown>; એݴϚʔδ͞Εͨ࠷ऴతͳܕΛར༻ͯ͠ ܕνΣοΫΛߦ͏
© Techtouch, Inc. 28 એݴϚʔδ͞Εͨ࠷ऴతͳܕΛར༻ͯ͠ ܕνΣοΫΛߦ͏ // ΞϓϦέʔγϣϯଆ: iframeScript.ts import
{ scrollTo } from "./PATH_TO/scrollTo.ts"; import { dispatchInput } from "./PATH_TO/dispatchInput.ts"; // import { getBoundingClientRect } from "./PATH_TO/getBoundingClientRect.ts"; export const iframeImplements = { scrollTo, dispatchInput, // getBoundingClientRect, // ^ ΈࠐΉͷΛΕͯ͠·ͬͨɺɺɺ } satisfies Record<keyof MessageMap, unknown>; // ❌ શͯͷϓϩύςΟ͕ἧ͍ͬͯΔ͜ͱΛݕࠪͰ͖Δ
© Techtouch, Inc. 29 ҙ
© Techtouch, Inc. 30 74$PEF্ͷܕνΣοΫͷද͕ࣔ UTDͷܕνΣοΫͷ݁ՌͱҟͳΔ߹͕͋Δ
© Techtouch, Inc. 31 74$PEF্ͰΤϥʔͷදࣔͰ
© Techtouch, Inc. 32 Ϗϧυ࣌ͷܕνΣοΫ௨Δ
© Techtouch, Inc. 33 wςοΫλονϞϊϨϙߏͰ wΤϯτϦϙΠϯτʢUTDPOGJHKTPOʣ͕ෳ͋Γ wએݴϚʔδ͞ΕΔܕ͕ΤϯτϦϙΠϯτ͝ͱʹҟͳΔ
© Techtouch, Inc. 34 74$PEFͰUTDPOGJHKTPO͕ෳ͋ͬͨ߹ʹɺ ͲͷUTDPOGJHKTPOʹج͍ͮͯܕνΣοΫ͢Εྑ͍͔ அͰ͖ͳ͍ͷͰͳ͍͔ʁ
© Techtouch, Inc. 35 ͦΜͳ͜ͱͳ͔ͬͨ
© Techtouch, Inc. 36 w ࠷খߏͰ࠶ݱڥΛࢼΈ͕ͨಉ͡ى͖ͳ͍ w 74$PEFෳͷUTDPOGJHKTPO͕͋ͬͯɺదͳUTDPOGJHKTPO ʹج͍ͮͯܕʹղܾͯ͘͠Εͨʢ͍͢͝ʣ
© Techtouch, Inc. 37 w ͳͷͰ·ͩ࠶ݱ݅Θ͔ͬͯͳ͍Ͱ͢ w ϞϊϨϙߏͷن͕େ͖͍ͱղܾ͢ΔએݴϚʔδͷ͕ଟ͘ͳΓɺҰ ఆͷΛ͑Δͱ࠶ݱ͢Δͷ͔͠Εͳ͍
© Techtouch, Inc. 38 ·ͱΊ
© Techtouch, Inc. 39 w ܕ҆શੑͱ֦ுੑͷཱ͕྆Մೳ w ϥΠϒϥϦͱΞϓϦέʔγϣϯؒͷॊೈͳܕఆٛΛ࣮ݱ w ϘτϜΞοϓͳܕఆٛͰϝϯςφϯεੑͷߴ͍ίʔυΛ࣮ݱ
JOUFSGBDFͷએݴϚʔδΛ׆༻͢Δ͜ͱͰ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂʂʂ
ͯ͢ͷϢʔβʔ͕ γεςϜΛ͍͜ͳͤΔੈքʹ γεςϜಋೖ͚ͩͰऴΘΒͤͳ͍ɺར׆༻ͷͨΊͷDXϓϥοτϑΥʔϜ
None