-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
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
From JSExport documentation it is not clear if enums, extension types and extensions can be annoteted with JSExport annotation or not. The following example works for me.
import 'dart:js_interop';
import 'dart:js_interop_unsafe';
@JS()
external void eval(String code);
@JSExport()
enum E {
e0(0);
final int id;
const E(this.id);
}
@JSExport()
class C {
int id = 42;
}
@JSExport()
extension type ET(C c) implements C {
}
@JSExport()
extension Ext on C {
int extensionMethod() => 42;
}
void main() {
var jsE = createJSInteropWrapper<E>(E.e0);
var jsET = createJSInteropWrapper<C>(ET(C()));
var jsC = createJSInteropWrapper<C>(C());
globalContext["jsE"] = jsE;
globalContext["jsET"] = jsET;
globalContext["jsC"] = jsC;
eval(r'''
console.log(globalThis.jsE.id); // 0
console.log(globalThis.jsET.c); // undefined
console.log(globalThis.jsC.id); // 42
console.log(globalThis.jsC.extensionMethod); // undefined
''');
}Metadata
Metadata
Assignees
Labels
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