I have this code in JS and I need to make it work in TypeScript.
categoryAxis.renderer.labels.template.adapter.add("dy", function(dy, target) {
if (target.dataItem && target.dataItem.index & 2 == 2) {
return dy + 25;
}
return dy;
});
On This 2 == 2
i am getting error.
If this is indeed the exact javascript you had :
target.dataItem && target.dataItem.index & 2 == 2
Then it is the same as
target.dataItem && target.dataItem.index & (2 == 2)
target.dataItem && target.dataItem.index & true
true will be coerced automatically by javascript as 1
, but TypeScirpt will not do that implicitly.
so if you write this :
target.dataItem && target.dataItem.index & 1
or
target.dataItem && target.dataItem.index & +true
in TypeScript, it compiles and does the same as your above javascript.
Otherwise your javascript was wrong already, and one of the other answers here already suggest xyou various corrections.