Re:Learn how to unleash the full potential of the type syste...
by KrishnaShripad on Wednesday September 21, 2022 @02:00PM
(#32928792)
Wow yeah it gets way too complex if you want to track the types of properties within the objects too! If that is the case, then I would just prefer to do this instead as it is much simpler:
type Value = { a: string }
const result = merge<Value, Value>({ a: 1 }, { a: "fdsfsd" })
EDIT: I think this is correct for when `exactOptionalPropertyTypes` is off.
That's for when `exactOptionPropertyTypes` is enabled. With it disabled, then you'd replace `Exclude<B[K], undefined>` with `B[K]`.As to whether this is a good idea. Ah... it's not :P