-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Sometimes it can be helpful to create a static private method and mark it with jsinterop to access some global value:
@JsType
public class MyExportedType {
//...
@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public interface PromiseSettled<T> {
String getStatus();
Object getReason();
T getValue();
}
@JsMethod(namespace = "Promise", name = "allSettled")
private static native <V> Promise<PromiseSettled<V>[]> allSettledInternal(IThenable<? extends V>[] promises);
}However, this ends up creating a new Promise type inside my output, even though the method is native:
export class Promise {
static allSettled<V>(promises:IThenable<unknown>[]):Promise<PromiseSettled<V>[]>;
}Workaround:
Move the single private method to its own class, or any other type that isn't meant to be exported
@JsType
public class MyExportedType {
//...
@JsType(isNative = true, namespace = JsPackage.GLOBAL)
public interface PromiseSettled<T> {
String getStatus();
Object getReason();
T getValue();
}
private static class PromiseHelper {
@JsMethod(namespace = "Promise", name = "allSettled")
private static native <V> Promise<PromiseSettled<V>[]> allSettledInternal(IThenable<? extends V>[] promises);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels