-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[breaking change] Change return type of unsignedRightShift #55238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As you say, if it returns an That'd be something like On Wasm, converting back and forth is not free. (Generally I'd prefer if the API kept values as JS values until the user requested a conversion to Dart value. Implicit conversion, especially if only in some cases, is harder to reason about. That all depends on the intended use-cases for the API. If we already do it for other members, it may be inconsistent to not do it here too.) |
Agreed that this is dependent on several factors. Some considerations:
These operators were added to support the interop API surface that already existed, so that users could migrate away from In this case:
cc @mkustermann
I generally want to avoid two versions for the same declaration just because of how large the API surface can get. We did this for members like |
@lrhn I think you convinced me of making these operators use JS types everywhere. :) If users didn't care about conversion costs with operators, they can use many of the Dart-equivalent operators anyways, so I suspect any use of these operators will be in cases where users would rather avoid the conversion cost. Furthermore, unlike So instead, I'm filing 55267 to break the two APIs that return a Closing this as not intended. Let me know if I labeled this incorrectly. |
Intended Change
dart:js_interop
'sunsignedRightShift
should now return anint
instead of aJSNumber
.dart:js_interop
exposes anunsignedRightShift
operator to be consistent with thedart:js_util
API. It currently returns aJSNumber
, but is always an integer value. Therefore, it should be anint
.Justification
Number and boolean conversions are a no-op in the JS compilers and fast in dart2wasm. Since the common use case will be to convert the
JSNumber
to anint
, we should offer an easier API for users so they don't have to convert the value with a.toDartInt
call. This is also consistent with the other exposed operators which returnbool
when the operator always returns a boolean value.Impact
Minimal. There are no usages in google3, in Flutter, in the SDK, or on GitHub.
Mitigation
Convert the resulting
int
to aJSNumber
withtoJS
if you still need theJSNumber
type e.g.The text was updated successfully, but these errors were encountered: