Open rileyporter opened 2 years ago
In #48515, I was trying to bind to the BigInt
wrapper object to deal with JavaScript APIs only supporting big ints.
For that, it would be great to have support for (all?) overridable Dart operators except for ~/
which doesn't exist in JS. There's also a question about **
which doesn't exist as an operator in Dart.
At the moment I'm implementing operators like this:
@JS('eval')
external Object _eval(String s);
bool Function(Object, Object) _leq =_eval('(a,b)=>a<=b') as bool Function(Object, Object);
This works but I really don't like it. Having these operators as binary functions in js_util
would already help a lot.
Currently we disallow all operators in JS interop classes. If we wanted to add support for them as instance members, the compilers would each need to implement each operator we wanted to allow.
However, we could support external operators in extensions, by lowering to js_util methods for some specific operators. For example, indexing could be lowered to
js_util.getProperty(foo, index)
andjs_util.setProperty(foo, index, value)
. This issue is to track what other operators we would want to support in extensions.