-
Notifications
You must be signed in to change notification settings - Fork 29
#3180. Add @staticInterop tests. Part 1.
#3256
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
Conversation
|
BTW @srujzs what types are allowed in an extension that provides members for import 'dart:js_interop';
@staticInterop
@JS()
class C {
}
extension Ext on C {
external String getString(); // Ok
external int getNumber(); // Ok
external bool getBool(); // Ok
external List<double> getList(); // Error: External JS interop member contains invalid types in its function signature: '*List<double>* Function()'.
external Object getObject(); // Error: External JS interop member contains invalid types in its function signature: '*Object* Function()'.
external JSObject getJSObject(); // Ok
} |
eernstg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a handful of comments. A couple of questions came to mind, in particular about the support for having a @staticInterop extension type, and the ability to compile invocations of external extension instance members as raw JavaScript invocations without @JS on the extension.
sgrekhov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One description has been updated. Let’s wait for @srujzs’s response. I couldn’t find any documentation on how this annotation is intended to be used or what its limitations are, so the tests were written assuming that the current behavior is correct
|
Tricky stuff! My general comments are:
This is one of the reasons why I wanted to move away from annotations with extension types with
https://dart.dev/interop/js-interop/js-types#requirements-on-external-declarations-and-function-tojs edit: Sorry for the back-and-forth around mixins. I believe we can modify our transformer and safely treat JS interop annotations on them as warnings, not errors. |
sgrekhov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Updated. Added new tests that expect errors/warnings for non JS interop classes annotated with @staticInterop. Removed tests checking that mixin and other types can be used in the interop. PTAL.
eernstg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@srujzs, it looks like you're happy about this PR at this time? I couldn't spot any comments from you that haven't been processed, as far as I can see.
I'll land it now, and if you have further comments then we can handle them in an additional PR.
2025-07-17 sgrekhov22@gmail.com dart-lang/co19#3180. Add `@staticInterop` tests. Part 1. (dart-lang/co19#3256) 2025-07-15 sgrekhov22@gmail.com dart-lang/co19#3180. Add tests checking `name` value (dart-lang/co19#3255) 2025-07-15 sgrekhov22@gmail.com dart-lang/co19#3180. Add `anonymous` annotation tests (dart-lang/co19#3254) 2025-07-15 sgrekhov22@gmail.com dart-lang/co19#3180. Add JSExport tests. Part 4. (dart-lang/co19#3253) Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,dart2js-minified-linux-d8-try Change-Id: Ice01c51e219f0ca68f92390db029ca3f8a65b7a8 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/441140 Reviewed-by: Chloe Stefantsova <cstefantsova@google.com> Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: Erik Ernst <eernst@google.com>
No description provided.