ignoring the possible mess when T and T2 have the same property name but different types, is this how I would right a (relatively) type safe graft function?
export function addPropFromOtherType<T extends object | null, T2, K extends keyof T2>(item: T, key: K, value: T2[K]): (T & T2[K]) | null {
if (!item) return null;
(item as any)[key] = value;
return item as T & T2[K];
}
Is there an easier way such that I could somehow specify just T2 at call sites so intellisense would detect my options for key?