typeStringKeys<Textendsobject>={[KinkeyofT]:T[K]extendsstring?K:never;}[keyofT];constconcatToField=<TextendsRecord<string,any>,KextendsStringKeys<T>>(obj:T,key:K,payload:string):T=>{constprop=obj[key]asunknownasstring;// compile error should not be herereturn{...obj,[key]:prop.concat(payload)};// compile error should not be here}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Discussion on: Advanced TypeScript Exercises - Question 8
For further actions, you may consider blocking this person and/or reporting abuse