-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-js-interopIssues that impact all js interopIssues that impact all js interop
Description
Dart version: 2.9.3~2.10.2
When using @JS()
js_interop with a Dart class like Win in js_interop.dart
and importing the library dart:js_util
in main.dart
together, all the methods defined inside Win will be lost in Dart2JS compiler.
For example,
main.dart
import 'dart:js_util';
import 'js_interop.dart';
main () {
/// The following code only works separately
window.eval('console.log("test")');
callMethod(window, 'eval', ['console.log("test2")']);
}
As you can see, if we comment out either line in the main function, it works well with Dart2JS compiler.
js_interop.dart
@JS()
library dart.issue.js;
import 'package:js/js.dart';
@JS()
@anonymous
abstract class Win {
external eval(String script);
}
@JS()
external Win get window
Here is a whole test project to demonstrate this issue - https://github.com/jumperchen/dart_interop_bug
Metadata
Metadata
Assignees
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-js-interopIssues that impact all js interopIssues that impact all js interop