Closed
Description
It would simplify a lot of use cases if we could override relational, equality, additive, and Multiplicative operators.
My initial thoughts on how this would work is that functions would replace the operators with functions when compiling to JavaScript.
class MyClass {
constructor() {
}
public Operator > (value: any):boolean {
// compare value
}
}
var myClass = new MyClass();
if(myClass > otherValue){
// Do stuff
}
Becomes:
var MyClass = (function () {
function MyClass() {
}
MyClass.prototype.greaterThan = function (value) {
// compare value
};
return MyClass;
})();
var myClass = new MyClass();
if (myClass.greaterThan(otherValue) {
// do Stuff
}