-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-dart2wasmIssues for the dart2wasm compiler.Issues for the dart2wasm compiler.web-js-interopIssues that impact all js interopIssues that impact all js interop
Description
import 'dart:js_interop';
@JS('jsFunction')
external void callJsFunction(JSAny? val);
@JS()
external set jsFunction(JSFunction f);
void main() {
void test<T extends JSAny?>() {
jsFunction = ((T t) {
return t;
}).toJS;
callJsFunction(null);
}
test<JSAny>();
void test2<T extends JSAny?>() {
final f = (T t) {};
(f as Function)(null);
}
test2<JSNumber>();
}test<JSAny> does not produce any errors, while test2<JSNumber> does the correct check on the parameter.
I had to disable some checks and remove some casts from the transformer to get a third test to work:
void test3<T extends int?>() {
jsFunction = ((T t) {
return t;
}).toJS;
callJsFunction(null);
}
test3<int>();but this also does not do a type-check, indicating that something about exporting the function is affecting the type-checking.
The callback should be called in the trampoline function, which is in Dart, so this shouldn't be an issue of the error escaping through JS.
Metadata
Metadata
Assignees
Labels
area-dart2wasmIssues for the dart2wasm compiler.Issues for the dart2wasm compiler.web-js-interopIssues that impact all js interopIssues that impact all js interop
Type
Projects
Status
Done