dev_compiler icon indicating copy to clipboard operation
dev_compiler copied to clipboard

Passing a Dart Type to interop lends a `WrappedType` instead of the real class

Open dam0vm3nt opened this issue 9 years ago • 1 comments

Any reference to a dart type like in :

  var x = MyTag

gets translated in

let x = dart.wrapType(index.MyTag);

So when passing a type to an interop call like in new JsObject.fromBrowserObject(h.document).callMethod("registerElement",['my-tag', x]); the native call receives a WrappedType instead of the actual Dart translated JS class.

Trying to "jsify" in the hope that the type will get unrwapped will ends up in an exception.

There should be a way to pass the actual class to native calls.

dam0vm3nt avatar Aug 26 '16 13:08 dam0vm3nt

@jacob314 -- should JS interop to provide some way to go from a Type to the corresponding JS constructor function? It seems like it, IMO.

@dam0vm3nt -- a workaround for now is to call dart.unwrapType(x) from JS.

jmesserly avatar Aug 26 '16 15:08 jmesserly