Skip to content

Need to support JS methods with names that are not valid Dart keywords #26531

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

Closed
ioancristea opened this issue May 25, 2016 · 3 comments
Closed
Labels
web-js-interop Issues that impact all js interop

Comments

@ioancristea
Copy link

Hi
Describe the issue you're seeing
I try to make a Dart version of the firebase 3 js. I need to create an external 'catch' method.

Does it happen in Dartium or when compiled to JavaScript?
When compiled to JavaScript

  • Dart SDK version: use dart --version
    Dart VM version: 1.16.0 (Tue Apr 26 14:18:21 2016) on "linux_x64"
  • pkg/js version: look at pubspec.lock
    js: ^0.6.0

Failing code:

@JS('Promise')
class Promise {
  external Promise(resolver);

  external all(List<Promise> values);
  external reject(error);
  external resolve(value);
  external catch([onReject]);
  external then([onResolve, onReject]);
}

Also i recive that error

FIREBASE WARNING: Exception was thrown by user callback. NoSuchMethodError: method not found: 'call'
Receiver: Closure 'AppComponent_closure'
Arguments: [null, null]
    at dart.wrapException (http://localhost:8080/main.dart.js:2818:17)
    at AppComponent_closure.dart.Object.noSuchMethod$1 (http://localhost:8080/main.dart.js:21524:17)
    at J.noSuchMethod$1$ (http://localhost:8080/main.dart.js:26288:39)
    at dart.Primitives_functionNoSuchMethod (http://localhost:8080/main.dart.js:2723:16)
    at dart.Primitives__genericApplyFunctionWithPositionalArguments (http://localhost:8080/main.dart.js:2758:20)
    at dart.Primitives_applyFunctionWithPositionalArguments (http://localhost:8080/main.dart.js:2744:16)
    at dart._callDartFunctionFast (http://localhost:8080/main.dart.js:23496:16)
    at http://localhost:8080/main.dart.js:23488:18
    at https://www.gstatic.com/firebasejs/3.0.2/firebase.js:346:688
    at https://www.gstatic.com/firebasejs/3.0.2/firebase.js:541:48

when i call this (the error is in allowInterop, without this is working fine)

firebase.database().ref('manufacturers').set(new firebase.TestSet(name: 'wefwef'), allowInterop(([error]) {
      window.console.debug('ss');
    }));
@floitschG floitschG added the web-js-interop Issues that impact all js interop label May 25, 2016
@DisDis
Copy link

DisDis commented May 25, 2016

possible duplicate #25785

@jacob314
Copy link
Member

jacob314 commented Jul 7, 2016

for method names that are not valid dart names you have to prefix them with
JS$
so
JS$catch
That will work in dart2js but support still needs to be added for dartium but will be straightforward to add.

@jacob314 jacob314 changed the title js-interop: Need to support JS methods with names that are not valid Dart keywords Jul 8, 2016
@jacob314
Copy link
Member

jacob314 commented Jul 8, 2016

This is the same issue as #26718

@jacob314 jacob314 closed this as completed Jul 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web-js-interop Issues that impact all js interop
Projects
None yet
Development

No branches or pull requests

4 participants