Currently there's some ECMA objects that are new or experimental that aren't available in Elemental2: ClipboardItem, Intl.Segmenter, etc.
I tried to add my own shims like:
@JsType(isNative = true, name = "Intl.Segmenter", namespace = GLOBAL)
public class Segmenter {
public Segmenter(String lang, JsPropertyMap<Object> options) {}
public native JsArray<Segment> segment(String text);
}
but I get various errors
Segment$$Overlay.impl.java.js:13: ERROR - variable Segment is undeclared
return instance instanceof Segment;
^
ProTip: "JSC_UNDEFINED_VARIABLE" or "checkVars" or "missingSourcesWarnings" or "undefinedVars" can be added to the `suppress` attribute of:
ERROR - Bad type annotation. Unknown type ClipboardItem
ProTip: "JSC_UNRECOGNIZED_TYPE_ERROR" or "checkTypes" or "unrecognizedTypeError" can be added to the `suppress` attribute
ERROR - Property segment never defined on segmenter
ProTip: "JSC_POSSIBLE_INEXISTENT_PROPERTY" or "checkTypes" or "globallyMissingProperties" or "missingProperties" or "missingSourcesWarnings" can be added to the `suppress` attribute
etc.
Since I have very minimal javascript I added the above to js_suppress, but is there a better/safer way to do this? I assume the reason elemental2 works while this doesn't is that elemental2 is checked against an internal js engine or something that doesn't have these defined (yet).
AFAICT, you need externs for all browser APIs. If these are not in Closure Library externs, then you have to write those and give them to the Closure Compiler.
Currently there's some ECMA objects that are new or experimental that aren't available in Elemental2: ClipboardItem, Intl.Segmenter, etc.
I tried to add my own shims like:
but I get various errors
etc.
Since I have very minimal javascript I added the above to
js_suppress
, but is there a better/safer way to do this? I assume the reason elemental2 works while this doesn't is that elemental2 is checked against an internal js engine or something that doesn't have these defined (yet).