@Colin
Ok so it does work using an *interface*! I just cannot declare a static
field *public static Car car* in the interface but introducing a Global
class to hold it does the trick!
@JsType(isNative = true)
public class Global {
@JsProperty(namespace = JsPackage.GLOBAL) public static Car
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
I think you can achieve this by using Babel: https://babeljs.io/ . A lot of
JS-Libs use this for shipping and "Legacy"-support. See also:
https://medium.com/hired-engineering/setting-up-monaco-with-jest-e1e4c963ac
Am Dienstag, 12. Mai 2020 12:14:50 UTC+2 schrieb Freddy Boucher:
>
> @Jens
>
>
@Jens
Good catch! It does work with the following javascript:
function Car() {
this.start = function () {
return "start";
}
}
var car = new Car();
But as you guessed, this is just some dummy code, my real javascript is the
Microsoft
Monaco Editor
> Other ideas?
>
Maybe because you have used a ES6 / ECMAScript2015 class in your custom JS
instead of a traditional function() based JS class. For example web
components also use ES6 classes and it is not straight forward to use them
with JsInterop / GWT.
I would start SDM / Compiler with
Thanks @Jens
So I added *namespace = JsPackage.GLOBAL* as suggested:
package com.project.client;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public class Car {
I am not 100% sure since I have not used JsInterop for a long time now but
I would imagine the following:
Currently GWT will think that your native JS class "Car" is located at
com.project.client namespace because that is the package it lives in and
you have not provided a namespace to
So I updated my sample project to remove the try/catch so it will throw the
JavaScriptException
Logger.getLogger("").info("direct call: " + Car.car.start());
List cars = Arrays.asList(Car.car);
for (Car car : cars) {
car.start();
}
Logger.getLogger("").info("It never goes here!!");
So here is
Hi @Jens
Can be project referring to my package name?
But I confirm the log is correct and it's produced by this exact sample
package com.project.client;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsProperty;
import jsinterop.annotations.JsType;
@JsType(isNative =
> But it fails with the following logs:
> direct call: start
> ConsoleLogger.java:33 FAILED to iterate a @JsType in a List
> ConsoleLogger.java:55 Exception:
> com.google.gwt.core.client.JavaScriptException: (TypeError) : Cannot read
> property 'project' of undefined
> ConsoleLogger.java:33
Hi,
So I don't know if it's a known JsInterop issue but here is my problem (PS:
I'm running GWT 2.9.0-RC1):
So in my home page I have the following code:
class Car {
start() {
return "start";
}
}
var car = new Car();
I have the following @JsType:
import jsinterop.annotations.JsPackage;
11 matches
Mail list logo