How to define external classes of a node module in separate files - kotlinjs

Viewed 23

I'm attempting to write a wrapper for an npm package but I cannot figure out how to define classes within a module in a separate file. It works fine if I do it within the single class but the file will end up being huge and messy if I go that route...

Imagine for example, there is this index.js file in the npm package:

module.exports = {
    AnotherClass: require('./somePath/AnotherClass')
}

Which I can do as:

@JsModule("testmodule")
@JsNonModule
external class TestModule {
    class AnotherClass {
        val someProperty: Type
    }
}

But I want to define AnotherClass in a separate (kotlin) file, just for better organisation and ease of navigation.

I've attempted (for sake of the example): @JsModule("testmodule/AnotherClass") as well as @JsModule("testmodule/somepath/AnotherClass") neither of which appear to work.

0 Answers
Related