-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionDuplicateAn existing issue was already createdAn existing issue was already createdOut of ScopeThis idea sits outside of the TypeScript language design constraintsThis idea sits outside of the TypeScript language design constraints
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
}
jonyrock, asheb, MeirionHughes, kakoi-to-muzhik, michaelmesser and 23 more
Metadata
Metadata
Assignees
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionDuplicateAn existing issue was already createdAn existing issue was already createdOut of ScopeThis idea sits outside of the TypeScript language design constraintsThis idea sits outside of the TypeScript language design constraints