Tiago Nunes
12/06/2020, 9:57 PMimplementation(npm("jquery", "3.5.1"))
implementation(npm("@types/jquery", "3.5.1", generateExternals = true))
However, I got a bunch of compile errors when running gradlew run, errors like:
'addEventListener' overrides nothing
'addEventListener' overrides nothing
'addEventListener' overrides nothing
'addEventListener' overrides nothing
'removeEventListener' overrides nothing
'removeEventListener' overrides nothing
Can dukat not yet convert declarations from @types/jquery 3.5.1?
How then can I use jQuery in kotlin (with declarations)?Robert Jaros
12/06/2020, 10:03 PMRobert Jaros
12/06/2020, 10:04 PMTiago Nunes
12/06/2020, 10:09 PMJoffrey
12/06/2020, 10:21 PMTiago Nunes
12/06/2020, 10:40 PMTiago Nunes
12/06/2020, 10:42 PMis-odd
Joffrey
12/06/2020, 10:59 PMoverride
modifiers when they should not be present (or missing interface most likely). Well as @Robert Jaros said, the project still has a bunch of quirks. What you can do as well is generate your externals "manually" using the jsGenerateExternals
gradle task, and then fix the declarations yourself by hand.Tiago Nunes
12/06/2020, 11:07 PMUnresolved reference. None of the following candidates is applicable because of receiver type mismatch
I've also tried jQuery declaration files from https://github.com/kotlin/js-externals, following the deprecation error message when defining external fun jQuery(selector: String): JQuery
, but the run task gives an error that, to me, looks like it isn't prepared for IR compiler.Tiago Nunes
12/06/2020, 11:08 PMTiago Nunes
12/06/2020, 11:30 PMRobert Jaros
12/07/2020, 1:18 AMimport pl.treksoft.jquery.jQuery
import pl.treksoft.jquery.invoke
Tiago Nunes
12/07/2020, 2:08 PMRobert Jaros
12/07/2020, 5:13 PM@nativeInvoke
annotation (which was working fine with auto-import). But it was deprecated and the inline extension function is a suggested change.
https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/js/src/kotlin/annotations.kt#L18
Unfortunately it doesn't work nice with auto-imports.