Lots of JS functions return Promise, and it results in lots of .await() in the user-code, and it is prone to error, as it is very easy to miss .await() call.
AFAIK xxxAsync functions are discouraged in Kotlin.
Adding explicit xxxAsync suffix to the imported from .d.tsPromise-returning functions makes it easier to spot that the result needs .await(), and it enables having a clean name for a suspending function.
For instance (@actions/io):
export declare function which(tool: string): Promise<string>;
The idea is to convert it as
@JsName("which")
external fun whichAsync(tool: String): Promise<String>
suspend fun which(tool: String) = whichAsync(tool, check).await()
I don't know if there's a generic way to handle definedExternally arguments.
Lots of JS functions return
Promise
, and it results in lots of.await()
in the user-code, and it is prone to error, as it is very easy to miss.await()
call.AFAIK
xxxAsync
functions are discouraged in Kotlin. Adding explicitxxxAsync
suffix to the imported from.d.ts
Promise
-returning functions makes it easier to spot that the result needs.await()
, and it enables having a clean name for a suspending function.For instance (
@actions/io
):The idea is to convert it as
I don't know if there's a generic way to handle
definedExternally
arguments.