One issue I faced was resolved by creating the function shown below :
function setProperty<T extends Record<string, string>>(obj: T, key: keyof T) {
obj[key] = "hello";
}
However, when I tried to compile the code, I encountered an error with obj[key]
highlighted in red and the following message displayed :
Type 'string' is not assignable to type 'T[keyof T]'.ts(2322)
I believe this error is due to the usage of the keyword "extends" but I am unsure how to resolve it.
Any guidance on this matter would be greatly appreciated. Thank you!