DEV Community

Discussion on: Advanced TypeScript Exercises - Question 8

Collapse
 
jfet97 profile image
Andrea Simone Costa • Edited

What about:

const concatToField =
  <K extends keyof T, T extends {[key in K]: string} >(obj: T, key: K, payload: string): T => {
    const prop = obj[key];
    return { ...obj, [key]: prop.concat(payload) };
}

?