I have a simple function that uses the keyof feature:
interface B {
name: string;
age: number;
}
function test(key: keyof B) {}
const c = {
age: 'age'
}
test(c.age);
The issue with the above code is that typescript throws an error that type string is not assignable to keyof B.
So what is the point of the keyof feature if it's not working with object key value? I don't want to add as keyof B.