Hello,
I'm getting this error with code:
/**
* @template {string} S
* @template {{ [key: string]: string }} OBJ
* @param {OBJ} obj
* @param {S} str
* @returns {{
* [K in keyof OBJ as `${str}${K}`]: OBJ[K] // <--- THIS DOESN'T THROW
* }}
*/
export function example(obj, str) {
return Object.entries(obj).reduce((acc, [key, val]) => {
acc[str + key]: val;
return acc;
}, /** @type {{ [K in keyof OBJ as `${str}${K}`]: OBJ[K] }} */ ({})) // <--- THIS THROWS ERROR
// ^
}
I'm not sure what is problem, because keyof OBJ should be string.