Skip to content

Run JS interop checks on Function.toJS calls emitted by createJSInteropWrapper #56792

@srujzs

Description

@srujzs

@JSExport relies on taking instance tear-offs and of "exportable" members and then calling Function.toJS on them. For Wasm compatibility, we should ensure that such functions respect the constraints of Function.toJS. Currently, the JS interop checks are done before this transform, so we should call out to those checks when we create the function in the transform.

Ideally, we'd be able to do this check on the class itself instead of when we invoke createJSInteropWrapper, but @JSExport is available both through dart:js_interop and through package:js, so this would be a breaking change for users using it through the old interop. We should also make sure to only emit these errors when createJSInteropWrapper is called and not createDartExport or createStaticInteropMock (available through js_util).

We could maybe make these errors surface better instead of all at the invocation site. Maybe emit the errors on the class when processing the invocation? We'd need to make sure we only do this once, however, so that multiple calls don't lead to a bunch of errors on the class.

Metadata

Metadata

Assignees

Labels

area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-js-interopIssues that impact all js interop

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions