constconcatToField=<TextendsRecord<string,any>,KextendskeyofT&(T[K]extendsstring?string:never)>(obj:T,key:K,payload:string):T=>{constprop=obj[key];// compile error should not be herereturn{...obj,[key]:prop.concat(payload)};// compile error should not be here}
Ah, was just missing some brackets. :/
Playground