How can I get Graal.js to handle a custom numeric Java type?

To dive in, we have an app where we have had Nashorn embedded.
With 17 I’m replacing it with GraalJS and there are some issues.
The current one is where I want GraalJS treat a custom class as an int (or double)for the purpose of basic arithmetic (+,- and so on). Right now, Graal.js can’t make head or tails of it so it just calls the toString method which isn’t optimal.
With Nashorn it sufficed to extend java.lang.Number but that doesn’t seem to work here.
I’ve looked in the interpreter code (I can’t find any relevant docs) and that shows that Graal.js can handle the various java.lang classes but I can’t figure out how to make it use custom classes.

The custom class has a lot of other func as well so I can’t throw it away and we have a large installed base of JS code that uses the custom class(es).

The JS code : function(e){print(e.id + 1)} where e is an object and id is a custom type (JSNumber that extends Number).

With Nashorn this worked (ie if id = 1, the result would be 2).
But, id is treated like a String and we get string concatenation instead, the result is 12.

Any links, hints or tips welcome!