interface Todo { id : number ; text : string ; completed : boolean ; } const todo = { id : 1 , text : "Buy milk" , completed : false } ; function prop < T , K extends keyof T > ( obj , key ) { return obj [ key ] ; } const id = prop ( todo , "id" ) ; const text = prop ( todo , "text" ) ; const completed = prop ( todo , "completed" ) ;