Based on the question, your professor has realised a limitation of TypeScript.
He has specifically asked you to make an add function. This is important because TypeScript doesn't support overloading of operators (such as +
).
However, you can write a function that accepts two ints and returns an int using the unary add operator as shown below. Only the code inside the function needs to understand there is odd stuff going on. Everything outside of the function thinks ints exist.
This wouldn't stop you from passing floats using the int type.
interface int extends Number {
}
function add(x: int, y: int) : int {
return +x + +y;
}
var a: int = 1;
var b: int = 2;
var c = add(a, b);