-
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.type-questionA question about expected behavior or functionalityA question about expected behavior or functionalityweb-js-interopIssues that impact all js interopIssues that impact all js interop
Description
I didn't find this info in JS interop documentation therefore the source of knowledge for me became this error message.
sdk/pkg/front_end/messages.yaml
Lines 6770 to 6772 in 0c34185
| JsInteropStaticInteropExternalFunctionTypeViolation: | |
| problemMessage: "External JS interop member contains invalid types in its function signature: '#string2'." | |
| correctionMessage: "Use one of these valid types instead: JS types from 'dart:js_interop', ExternalDartReference, void, bool, num, double, int, String, extension types that erase to one of these types, '@staticInterop' types, 'dart:html' types when compiling to JS, or a type parameter that is a subtype of a valid non-primitive type." |
According to the above dart:html types are allowed in JS interop members (in case of dart2js). But the following code doesn't work for me.
import 'dart:html';
import 'dart:js_interop';
extension type ET._(JSObject _) implements JSObject {
external ET.fromElement(Element e);
}
main() {
Element e1 = DivElement();
ET et1 = ET.fromElement(e1); // TypeError: init.G.ET is not a constructor
}@srujzs is this a wrong test, issue or just an obsolete error message?
Dart SDK version: 3.10.0-edge.b5c5ad0aac1d9477e7d417ebd6ac2af63150c0cc (main) (Thu Aug 14 22:24:42 2025 -0700) on "linux_x64"
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.type-questionA question about expected behavior or functionalityA question about expected behavior or functionalityweb-js-interopIssues that impact all js interopIssues that impact all js interop