Skip to content

[dart:js_interop] Add an option to ignore rest arguments when passing Dart functions to methods like Array.map. #55245

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
ykmnkmi opened this issue Mar 20, 2024 · 1 comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-js-interop Issues that impact all js interop

Comments

@ykmnkmi
Copy link
Contributor

ykmnkmi commented Mar 20, 2024

For example (Array.map):

import 'dart:js_interop';

@JS('eval')
external void eval(String code);

@JS('do_work')
external void doWork(JSFunction callback);

void main() {
  eval('''
const array = [1, 2, 3, 4];
window.do_work = (callback) => {
  array.map(callback);
};
''');

  doWork(((JSAny? item, /* index, array */) => print(item)).toJS);
}

Throws with Dynamic call with too many positional arguments. Expected: 1 Actual:... (NativeError).

@mit-mit mit-mit added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Mar 20, 2024
@Markzipan Markzipan added the web-js-interop Issues that impact all js interop label Mar 21, 2024
@srujzs
Copy link
Contributor

srujzs commented Mar 21, 2024

Duplicate of #48186. We should do this by default, I don't see a strong reason to make this optional.

@srujzs srujzs closed this as completed Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-js-interop Issues that impact all js interop
Projects
None yet
Development

No branches or pull requests

4 participants