Skip to content
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

Use operator methods in JS interop #46359

Closed
jodinathan opened this issue Jun 15, 2021 · 1 comment
Closed

Use operator methods in JS interop #46359

jodinathan opened this issue Jun 15, 2021 · 1 comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. closed-duplicate Closed in favor of an existing report web-js-interop Issues that impact all js interop

Comments

@jodinathan
Copy link

I have built a JS bindings package that read WebIDLs and MDN to generate JS wrappers with package:js: https://pub.dev/packages/js_bindings

When I try to use the package, it throws this error while compiling:
JS interop classes do not support [] and []= operator methods.

Will you support operator methods in JS?
How can I work this around?

This tracker is for issues related to:

  • dart2js
    Dart SDK version: 2.13.1 (stable) (Fri May 21 12:45:36 2021 +0200) on "macos_x64"
@mraleph mraleph added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Jun 15, 2021
@sigmundch sigmundch added the web-js-interop Issues that impact all js interop label Jun 15, 2021
@sigmundch
Copy link
Member

Thanks @jodinathan for filing this issue. I'll mark this as a duplicate of the general bug #35084 where we are tracking the general effort of revamping JS-interop using a static approach.

Many of our historical limitations (like renaming members, using operators, processing inputs and outputs) are an unfortuante result of our current implementation strategy. As I hinted in #46248, we do allow to use index operators with static extension methods. For example:

@JS()
class A { external A(); }
extension AExtension on A {
   String operator[](String y) => js_util.getProperty(this, y);
}

@sigmundch sigmundch added the closed-duplicate Closed in favor of an existing report label Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. closed-duplicate Closed in favor of an existing report web-js-interop Issues that impact all js interop
Projects
None yet
Development

No branches or pull requests

3 participants