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
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
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
420
開発に寄りそう自動テストの実現
goyoki
2
1.5k
GISエンジニアから見たLINKSデータ
nokonoko1203
0
190
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
11
4.4k
PC-6001でPSG曲を鳴らすまでを全部NetBSD上の Makefile に押し込んでみた / osc2025hiroshima
tsutsui
0
200
生成AI時代を勝ち抜くエンジニア組織マネジメント
coconala_engineer
0
32k
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
420
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
140
TerraformとStrands AgentsでAmazon Bedrock AgentCoreのSSO認証付きエージェントを量産しよう!
neruneruo
4
2k
Canon EOS R50 V と R5 Mark II 購入でみえてきた最近のデジイチ VR180 事情、そして VR180 静止画に活路を見出すまで
karad
0
140
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
910
AIエージェントの設計で注意するべきポイント6選
har1101
6
2.6k
Featured
See All Featured
Test your architecture with Archunit
thirion
1
2.1k
Side Projects
sachag
455
43k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
140
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.1k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
53
47k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
350
Being A Developer After 40
akosma
91
590k
We Are The Robots
honzajavorek
0
120
The SEO Collaboration Effect
kristinabergwall1
0
310
Darren the Foodie - Storyboard
khoart
PRO
0
2k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.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