Closed
Description
There are many invalid things that can be done with JS interop, but we don't have static errors for this.
Here are some examples of things that should be reported (or else, need to be specified and fixed in the DDC/dart2js):
- an anonymous JS class with positional arguments in the constructor. This is invalid, because it's supposed to create an object literal, and causes a DDC crash (see Error compiling dartdevc module #32031)
- use of generic functions/methods (currently unsupported in JS interop)
- use of generic classes (what is intended behavior?)
- use of
@JS
on a class/library member without a@JS
on the library - use of
@JS
on a class member instead ofexternal
- declaring Dart members on a
@JS
class (Dart code is silently ignored) - extends/mixin
@JS
classes from a Dart class (also unclear ifimplements
is supported) - extends/mixin/implements Dart class from
@JS
class
Errors should be reported from Analyzer so people can see the problem sooner. (Once DDC migrates to Kernel, need a way of calling into Analyzer to produce these kinds of errors. Or we just have shared code between dart2js/DDC for validating JS interop usage.)
Also it would be lovely to have a specification. These would be useful:
- where is
@JS
allowed to appear? - where is
external
allowed to appear? - inheritance implications of the various permutations of Dart and JS classes and member kinds
- interaction with Dart generic classes
- interaction with Dart generic methods/functions
- meaning of Dart members on a JS class
- semantics of anonymous JS types
- how JS types fit into the Dart subtyping relation and Dart Type equality
- how JS functions related to the Dart type system
- static and dynamic call/get/set/index/operator/tearoff semantics
- behavior of dart:core Object members (toString, hashCode, operator ==, noSuchMethod, runtimeType) for JS objects
- interaction with the JS global namespace
- interaction with JS modules