Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.promises API does not seem to work #5

Open
vlsi opened this issue Aug 2, 2020 · 3 comments
Open

fs.promises API does not seem to work #5

vlsi opened this issue Aug 2, 2020 · 3 comments

Comments

@vlsi
Copy link

vlsi commented Aug 2, 2020

See https://nodejs.org/api/fs.html#fs_fs_promises_api

The fs.promises API provides an alternative set of asynchronous file system methods that return Promise objects rather than using callbacks. The API is accessible via require('fs').promises or require('fs/promises')

It looks like fs.promises is not right here:

I'm not sure what declare module "fs/promises" means in TypeScript, however, the following Kotlin declaration works:

@file:JsModule("fs")
@file:JsQualifier("promises")
package ...

import kotlin.js.Promise

external fun unlink(paths: String): Promise<Unit>
@vlsi
Copy link
Author

vlsi commented Aug 2, 2020

@file:JsModule("fs/promises") produces

Caused by: java.lang.IllegalStateException: Module 'fs/promises' not found
        at org.jetbrains.kotlin.gradle.internal.ExecKt$execWithErrorLogger$1.invoke(exec.kt:91)
        at org.jetbrains.kotlin.gradle.internal.ExecKt$execWithErrorLogger$1.invoke(exec.kt)
        at org.jetbrains.kotlin.gradle.internal.ProgressKt.operation(progress.kt:23)
        at org.jetbrains.kotlin.gradle.internal.ProgressKt.operation$default(progress.kt:15)
        at org.jetbrains.kotlin.gradle.internal.ExecKt.execWithErrorLogger(exec.kt:75)
        at org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackRunner.execute(KotlinWebpackRunner.kt:24)
        at org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack.doExecute(KotlinWebpack.kt:229)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:49)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:42)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:726)
        at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:693)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$3.run(ExecuteActionsTaskExecuter.java:569)

@vlsi
Copy link
Author

vlsi commented Aug 2, 2020

The following works (I'm not sure if it should work or if it should not):

@file:JsModule("fs")
@file:JsQualifier("promises")
package ...

import kotlin.js.Promise

external fun unlink(paths: String): Promise<Unit>

@turansky
Copy link

turansky commented Aug 2, 2020

cc @ilgonmic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants