I have this code in JS and I need to make it work in TypeScript.
It keeps saying:
The right hand side of an arithmetic operation must be of type 'any', 'number' or an enum type
sort(field, reverse, primer) {
var key = primer ?
function(x) {return primer(x[field])} :
function(x) {return x[field]};
reverse = [-1, 1][+!!reverse];
return function (a, b) {
return a = key(a), b = key(b), reverse * ((a > b)) - (b > a));
}
}
Any ideas?
reverse * ((a > b))
this is number * boolean. – ASDFGerte-
will convert back to numeric. In any case the OP has Typescript code, not JavaScript code. – Pointy