I'd like to write a typescript function that accepts arguments like this:
myFunc([
{
initialValue: 6, // number
finalValue: 8 // number
},
{
initialValue: 'hello', // string
finalValue: 'goodbye' // string
}
])
But will fail if given this:
myFunc([
{
initialValue: 6, // number
finalValue: 'goodbye' // should fail because not a number!
}
])
It feels like the solution should entail generics, but generics that are generic within each array item, not generic across the whole array.
EDIT: I'd like a solution that works with ANY type of value, not just strings or integers. I will likely need to use this for classes/functions as well.