-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed as not planned
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.triage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-enhancementA request for a change that isn't a bugA request for a change that isn't a bugweb-js-interopIssues that impact all js interopIssues that impact all js interop
Description
Current:
import 'dart:js_interop';
typedef EventDispatcher<T> = bool Function(
String type,
T detail, {
bool cancelable,
});
@anonymous
extension type _EventDispatcherOptions._(JSObject _) implements JSObject {
external factory _EventDispatcherOptions({bool cancelable});
}
@JS('createEventDispatcher')
external JSFunction _createEventDispatcher();
EventDispatcher<T> createEventDispatcher<T>() {
var jsFunction = _createEventDispatcher();
return (
String type,
T detail, {
bool cancelable = false,
}) {
var jsResult = jsFunction.callAsFunction(
null,
type.toJS,
// ignore: invalid_runtime_check_with_js_interop_types
ref(detail) as JSAny?,
_EventDispatcherOptions(cancelable: cancelable),
) as JSBoolean;
return jsResult.toDart;
};
}Expected:
import 'dart:js_interop';
typedef EventDispatcher<T> = bool Function(
String type,
T detail, {
bool cancelable,
});
@anonymous
extension type _EventDispatcherOptions._(JSObject _) implements JSObject {
external factory _EventDispatcherOptions({bool cancelable});
}
typedef _JSEventDispatcher<T> = bool Function(
String type,
ExternalDartReference<T> detail, [
_EventDispatcherOptions options,
]);
@JS('createEventDispatcher')
external _JSEventDispatcher _createEventDispatcher();
EventDispatcher<T> createEventDispatcher<T>() {
var jsFunction = _createEventDispatcher();
return (
String type,
T detail, {
bool cancelable = false,
}) {
return jsFunction(
type,
// ignore: invalid_runtime_check_with_js_interop_types
ref(detail),
_EventDispatcherOptions(cancelable: cancelable),
);
};
}PS: I miss and pressed Enter while editing.
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.triage-automationSee https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.type-enhancementA request for a change that isn't a bugA request for a change that isn't a bugweb-js-interopIssues that impact all js interopIssues that impact all js interop