Quiero crear una nueva función a partir de una función inicial, con la función inicial tomando un argumento de un solo objeto y la nueva función tomando el mismo argumento de un solo objeto aparte de los campos poblados. Tengo algo como esto hasta ahora:
function returnNewFunc<TArg extends { b?: string }>( initialFunc: (arg: TArg) => void ) { const newFunc = (arg: Omit<TArg, "b">) => initialFunc({ ...arg, b: "hello" }); return newFunc } const funcA = ({ b, c }: { b: string; c: string }) => { console.log(b, c); }; const funcB = returnNewFunc(funcA) funcB({c: "test"}) // funcB should have 'c' as the only field in its argument El problema aquí es que se could be instantiated with a different subtype of constraint , por lo que debo estar haciendo algo mal.