As an illustration, imagine I have the following interface:
interface Bar {
value1: number;
value2: number;
}
I want to include a method called calculateSum() that will return the sum of values on any object implementing this interface. How can this be achieved in Typescript?
I am looking to create a function like this:
function outputBarSum(bar: Bar) {
console.log(???);
}
This function should not require manually assigning properties from bar to another class.