Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Strip Types と Storage

Strip Types と Storage

東京Node学園 43時限目で発表した Strip Types と Storage の話です。

Yosuke Furukawa

August 08, 2024
Tweet

More Decks by Yosuke Furukawa

Other Decks in Programming

Transcript

  1. strip types • ܕΛιʔείʔυ͔ΒҾ͖ൈ͍ͯ TypeScript ϑΝΠϧΛ JavaScript ϑΝΠϧ ʹม׵ͨ͠͏͑Ͱ࣮ߦ͢Δͱ͍͏΋ͷ •

    ͜ΕͰ TypeScript ͷϑΝΠϧΛʢҰఆͷ੍໿৚݅Խʹ͓͍ͯ͸ʣͦͷ··࣮ ߦͰ͖ΔΑ͏ʹͳͬͨɻ • Ұఆ৚݅: enum, namespace, decorator ͳͲͷػೳʹؔͯ͠͸ܕΛऔΓআ͘ ͚ͩͰ͸ͳ͘ɺผίʔυΛੜ੒͢Δ΋ͷͳͷͰ͜͜Ͱ͸αϙʔτର৅֎
  2. strip types • ͜ͷ݅ʹରͯ͠ͷҰਓࢍ൱ • ࢍ • ૉ੖Β͍͠ʂʂʂʂ TypeScript ࠷ߴʂʂʂʂ

    • ΍ͬͺΓͶɺͦͷ··ಈ͘ͷͬͯྑ͍ΑͶ • Bun, Deno ͱ͔΋ಉ͡ػೳΛఏڙͯ͠Δ͠ɺ͜ΕͰTypeScriptαϙʔτ Ͱʮ͋Ε͕Ͱ͖ͳ͍ɺ͜Ε͕Ͱ͖ͳ͍ʯͱݴΘΕΔ͜ͱ͕ͳ͍Ͷ
  3. strip types • ͜ͷ݅ʹରͯ͠ͷҰਓࢍ൱ • ൱ • tscon f ig.json͕αϙʔτ͞Εͳ͍ͬͯɺඍົͳͱ͜ΖͰಈ͔ͳ͔ͬͨΓ͢

    ΔͰʁ • ֦ுࢠɺϑΝΠϧύεɻɻɻ • ͋ͱ tsc ͰͷνΣοΫ͕ͳ͍ͷʹ TS αϙʔτͬͯ • ݴͬͪΌ͏ͷ͸ݫ͍ͬͯ͠
  4. strip types • TypeScript αϙʔτ͍ͬͯ͏ݴ༿͸৻ॏʹʂʂʂ // DEMO interface Point {

    x: number; y: number; } function logPoint(p: Point) { console.log(`${p.x}, ${p.y}`); } // logs "12, 26" const point = { x: 12, y: 26 }; logPoint(point); // node --experimental-strip-types foo.ts
  5. storage • ͜ͷ݅ʹରͯ͠ͷҰਓࢍ൱ • ൱ • ʮͨͩ͊͋͋͋͋͋ʔʔʔʔʔʂʂʂʂʂʯ • ʮ͍͍͍͍͍ΒͶ͑͑͑͑͑͑͑͑͑͑͑͑͑͑ʂʂʂʂʂʂʯ •

    syncͰอଘ͞ΕΔσʔλʹྑ͞Λશ͘ײ͡ͳ͍ • ·ͩasyncʹͳΔͳΒΘ͔ΔɻͰ΋ͦΕͳΒશ͘ผͷ֓೦Ͱ AsyncLocalStorage ͱ͍͏API͕͋Γɺ༻ҙ͠Α͏ʹ΋طʹऔΒΕͯΔɻ(※Θ͔Γʹ͍͘ͱࢦఠ͕͋ͬ ͨͨΊ௥ه)
  6. storage • ͜ͷ݅ʹରͯ͠ͷҰਓࢍ൱ • ࢍ • ͑ɺͰ΋Bun͸sqlite࠷ॳ͔Βೖͬͯ·͢Α • cloud f

    lare workersͱ͔ʹ΋KV Storage͕͋Δ • खܰʹ࢖͑ΔετϨʔδ͸΄͍͠Ͱ͠ΐʁ
  7. Node.jsʹݶΒͣ • State of JS 2024 ͷ๯಄ʹॻ͍ͯ͋Δ • ๻Β͸ͣͬͱϑϨʔϜϫʔΫ΍ΤίγεςϜʹৼΓճ͞ΕͯΔ •

    ͦΕΛࢦͯ͠ fatigueʢർฐʣ ʹؕΔ͜ͱ΋͋Δ • ͨͩͦ͏͍͏ early adapter Λ௥͏ඞཁ͸ͳ͍ • ࣗ෼ͨͪͷϖʔεͰ௥͏͜ͱ͕ॏཁͳΜͩ