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

[dart:js_interop] Can't pass an function reference to external function when assertions are enabled. #55549

Closed
ykmnkmi opened this issue Apr 23, 2024 · 1 comment
Assignees
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-js-interop Issues that impact all js interop

Comments

@ykmnkmi
Copy link
Contributor

ykmnkmi commented Apr 23, 2024

For example:

import 'dart:js_interop';

@JS('set_property')
external void _setProperty(JSObject object, String name, ExternalDartReference? value);

void setProperty(JSObject object, String name, Object? value) {
  _setProperty(object, name, value?.toExternalReference);
}

throws this (DDC, dart2js)

Assertion failed: "Dart function requires `allowInterop` to be passed to JavaScript."

Dart SDK version: 3.5.0-edge.936b3a2ccf38aaf8ab3cd7e50f84231a053d669c (main) (Wed Apr 10 23:48:20 2024 +0000) on "windows_x64".

@mraleph mraleph added web-js-interop Issues that impact all js interop area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels Apr 24, 2024
@srujzs srujzs self-assigned this Apr 24, 2024
@srujzs
Copy link
Contributor

srujzs commented Apr 24, 2024

This was needed with previous versions of interop as we didn't have enough static type information. I think we can safely disable the checks for dart:js_interop methods. While it's possible users might try to use this Dart function in JS, that's much less likely than wanting to pass a Dart function around using ExternalDartReference.

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. web-js-interop Issues that impact all js interop
Projects
Status: Done
Development

No branches or pull requests

3 participants