Let say I have an interface like this
interface I{
id: string;
name: string;
age: number;
}
and a method like this
var obj:I={
id: 'abc',
name: 'Jim',
age: 23
};
changeProperty(name:string, value:any){
obj[name] = value;
}
Is there a way to declare the name parameter type to match interface fields?
One solution would be something like this
changeProperty(name: 'id' | 'name' | 'age' , value:any)
but in a much larger project where an interface can have 20+ fields it's much harder to maintain this.