kotlin-suspend-transform-compiler-plugin icon indicating copy to clipboard operation
kotlin-suspend-transform-compiler-plugin copied to clipboard

JS transform suspend with Result return type to Promise

Open Yentis opened this issue 5 months ago • 3 comments

I was wondering if it would be possible to have a transformer that converts suspend fun foo(): Result<String> to fun foo(): Promise<String> instead of fun foo(): Promise<Result<String>>

I was thinking something like

fun <T> toAsync(block: suspend () -> Result<T>): Promise<T> {
    return coroutineScope.promise { block().getOrThrow() }
}

which technically works as a custom transformer but the return type isn't correct

Yentis avatar Jun 23 '25 12:06 Yentis