-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[jsinterop] Complete static JSInterop implementation #49353
Comments
/cc @srujzs @rileyporter @joshualitt - feel free to edit the list above |
There have been a lot of changes here since the initial post, namely adding support for dart2wasm JS interop, JS types, and interop with extension types. JS types refer to the set of types we expose through There will be docs added to dart.dev with all these changes in the near future, but for those working with next-gen interop/interested in migration, there are a few key discrepancies that we're aware of that we want to highlight with - Runtime type differences of JS types On the JS compilers, JS types generally have a more specific Dart type that they are intercepted to. - Conversions between The default There is a Conversions from an Therefore, if you know you’re going to need to eventually pass the list to JS, and you care about modifications persisting, instantiate a - Conversions for
Unlike Like Therefore, if you care about modifications persisting, instantiate a JS typed array. Use - Native Dart code and Web Dart code differ in number semantics today: https://dart.dev/guides/language/numbers#differences-in-behavior. dart2wasm will conform to the Native semantics (even though it says "Web" 😄):
In the JS compilers, JS This is not the case in dart2wasm. dart2wasm’s Avoid code where this matters for now. In the future, we might provide an annotation that you can use on In general, stick with Also, avoid casts in favor of conversion functions. As mentioned above, casts may succeed on one backend but fail on another. Similarly There may be missing members that we’ll add to the JS types, but you can add missing members either through your own interop interface or through an extension. You can define an interop interface using an extension type (with a JS type representation type) or through |
Will |
That's the plan! The goal is to lock down |
This is a meta bug to track all of our efforts in implementing and releasing the next generation of JSInterop based on extension types.
We are also using https://github.com/orgs/dart-lang/projects/65/views/1 to track some items with more agility. We'll try to periodically update this issue as well.
JS interop must have:
dart:js_interop
library@staticInterop
andextension type
js_util
style methods indart:js_interop
anddart:js_interop_unsafe
@JS
annotations and@staticInterop
indart:js_interop
dart:js_interop
@staticInterop
docs site-www#4331Package web must have:
extension types
Ecosystem:
dart:js_interop
andpackage:web
Desirables that can be shipped later:
legacy_js_interop
#58957)@JS
annotation where needed, addimplements JSObject
)is JsFoo
)@staticInterop
to the new language syntaxdart:js
todart:js_util
package:js
JSInterop to the new styleOther issues to add above:
--warn-on-legacy-js-interop
flag to JS compilers (dart2js & DDC) #50665The text was updated successfully, but these errors were encountered: