mmaillot
03/02/2018, 9:37 AM@JsModule("express")
external class Express {
fun get(route: String, callback: (req: Request, res: Response) -> Unit)
fun listen(port: Int, callback: Callback?)
}
And I create a class ExpressKt to overload express :
class ExpressKt(private val express: Express = Express()) {
fun listen(port: Int, callback: Callback) {
express.listen(port, callback)
}
}
And finally the code to run :
fun main(args: Array<String>) {
//val app = Express()
val app = ExpressKt()
app.listen(3000, {
println("Listening on port 3000")
})
}
But when i compile code, the index import the wrong library (module.exports, require('kotlin'), require('lib'))
mmaillot
03/02/2018, 9:39 AMmodule.exports, require('kotlin'), require('express'))
mmaillot
03/02/2018, 9:39 AMmmaillot
03/02/2018, 9:40 AMmmaillot
03/02/2018, 9:51 AManton.bannykh
03/02/2018, 11:01 AMrequire('express')
in the lib.js
originally?mmaillot
03/02/2018, 11:04 AMmmaillot
03/02/2018, 11:04 AMmmaillot
03/02/2018, 11:05 AManton.bannykh
03/02/2018, 11:06 AMrequire('express')
then it works as intendedanton.bannykh
03/02/2018, 11:06 AManton.bannykh
03/02/2018, 11:07 AManton.bannykh
03/02/2018, 11:07 AMmmaillot
03/02/2018, 11:10 AManton.bannykh
03/02/2018, 11:17 AMjs
file? How familiar are you with JS tools (e.g. npm, webpack, etc)?anton.bannykh
03/02/2018, 11:17 AManton.bannykh
03/02/2018, 11:24 AManton.bannykh
03/02/2018, 11:24 AMmmaillot
03/02/2018, 12:06 PManton.bannykh
03/02/2018, 12:09 PManton.bannykh
03/02/2018, 12:12 PMbuild
directory) is also a reasonable starting point to get familiar with webpack, npm, karma, etc.anton.bannykh
03/02/2018, 12:12 PMmmaillot
03/02/2018, 1:42 PManton.bannykh
03/02/2018, 2:19 PMmmaillot
03/02/2018, 2:38 PManton.bannykh
03/02/2018, 2:51 PM.meta.js
at the minimum, and optionally js.map
, and *.kjsm
files for best experience.mmaillot
03/02/2018, 2:56 PM