I like the tricks :) – Kasia
Instead of keeping the index and array separated, use a zip list.
type SlideDeck = { slides: Slide[], selected: number, } const carousel: SlideDeck = { slides: [], // ⛔️ There should be at least one selected: -10, // ⛔️ WTH? }
type SlideDeck = { before: Slide[], current: Slide, after: Slide[], } // ✅ Always one slide with 0 or more before and after
Crafted with 💛 by Riccardo