I like the tricks :) – Kasia
If you want to avoid undefined, Pick may be a better option.
type Options = { a: string, b: string } const defaults = { a: 'a', b: 'b' } const update = (override: Partial<Options>): Options => ({ ...defaults, ...override }) update({ a: undefined }) // ⛔️ { "a": undefined, "b": "b" }
const update = <K extends keyof Options> (override: Pick<Options, K>): Options => ({ ...defaults, ...override }) update({ a: undefined }) // ✅ Does not compile
Crafted with 💛 by Riccardo