Hi, i am trying to use `<https://www.npmjs.com/pac...
# javascript
u
Hi, i am trying to use
<https://www.npmjs.com/package/@abandonware/noble>
with dukat:
Copy code
implementation(npm("@abandonware/noble", "1.9.2-7"))
The problem is, that dukat only generates top level functions which can not be resolved at runtime:
Copy code
@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "EXTERNAL_DELEGATION")

import ...

external fun startScanning(callback: (error: Error) -> Unit = definedExternally)
If a add my own type definitions like that things work:
Copy code
@file:Suppress("INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS", "EXTERNAL_DELEGATION")

val noble: Noble = js("require('@abandonware/noble')")

external class Noble : events.EventEmitter {
    fun startScanning(callback: (error: Error) -> Unit = definedExternally)
Am I donig something wrong? Are the type script definitons of the package broken? Or is it just dukat? Btw. the project is compiled with
Copy code
kotlin {
    target {
        useCommonJs()
        nodejs()
t
Is there js module annotation in dukat output?
u
I don't think so. Should it be at the head of the file? This is verbatim copied above.
Here is the genrated file
I am pretty new to the JS/TS world. But to me it looks like the .d.ts file is already missing module information? https://github.com/abandonware/noble/blob/master/index.d.ts
t
Looks like you need add JsModule only in head
u
But dukat will overwrite it the next time. Right?
t
Yes, but if JsModule resolve the problem, than you can apply WA in custom task and create ticket on dukat
One more option - use latest dukat, possibly bug is already fixed
u
can i tell gradle to use latest dukat?
👌 1
And how would dukat know the module name. I did not find anything in d.ts file
t
module name = npm module name
u
ah. thanks
t
index.d.ts - default definitions
u
so maybe the
@
is the problem for dukat
t
Possibly it’s already fixed - https://www.npmjs.com/package/dukat
u
Can I tell my gradle build to use a more recent dukat?
I mean currently dukat is run automatically from my project's build gradle
t
If latest dukat won’t resolve problem, then you can create temp WA in custom task
u
thanks for your support. It was realla helpful. I'll just copy the fixed version of the generated file for now.
🙂 1
t
Do you check latest dukat version?
28
?
u
Yes I did. Still broken. So I added a note about noble to the ticket you mentioned above
t
@uli Whick kotlin version do you use?
u
1.3.71 and 1.4-M1. Same result