type KitPluginPatch = { options?: Record; } & Record; type ConfigurableKitPlugin = { key: string; options?: Record; configure: (config: Record) => unknown; }; export function overrideKitPlugin( kit: readonly T[], key: string, patch: KitPluginPatch, ): T[] { return kit.map((plugin) => { if (plugin.key !== key) { return plugin; } const nextConfig = { ...patch, options: { ...(plugin.options ?? {}), ...(patch.options ?? {}), }, }; return plugin.configure(nextConfig) as T; }); }