Tuesday, May 12, 2020

Re: JsInterop - fail to iterate @JsType in List

Another option could be to tell GWT that this is just the idea of what the Car type will be, but that there isn't actually a real type called Car that it will be able to find. For example, you could perhaps make this an interface instead of a class (js has no actual interface types, just "it quacks, so its a duck"). Another option (but not a good one) is to further modify the `@JsType` to have `name="Object", so that GWT ignores all type checks. This will get weird in j2cl though, as you'll need externs that reflect this code style (though you'll need externs anyway, if monaco isn't capable of being fed to closure-compiler).

I do believe that the es2015 class keyword emits a constructor that GWT can work with though - the limitations for GWT and WebComponents are that you can't "extend" a es2015 class using prototype, and GWT always uses prototype.

If the script block does some scoping (modules perhaps?) that could hide the Car type from GWT, so that it is unable to do the JS `(c instanceof $wnd.Car)` check required to cast the element when it comes out of the generic ArrayList<Car>.get().

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/c8f20354-7b33-4285-881c-521b44896dee%40googlegroups.com.

No comments:

Post a Comment