This function resolves the problem with different values in a function or class.
Example: We have a function with different parameters and descriptions like:
interface MyExample1 {
count: number;
cost: number;
}
interface IMyExample2{
items: string[];
cost: number
}
// The simple function returned
function Sum(data: MyExample1|IMyExample2) {
return cost * (isItType<MyExample1>(data, "count") ? count : items.lenght);
}The function isItType help understand with the exact interface we are using at this time.