Hi, are there any samples of how to setup gradle t...
# javascript
k
Hi, are there any samples of how to setup gradle to use my modified dukat typings? What dukat generates unfortunately doesn't compile so I'd like to use the ones I adjusted to compile. But I can't get it to work. It compiles but the imports/requires aren't added to the outputted js file. Any hints?
l
Do you have a
Copy code
@file:JsModule("name-of-module")
at the top of the definition file?
k
Does that go in every module file? I'm trying to use aws-cdk and dukat generated like 25 files. Do I then add `@file:JsModule("aws-cdk/aws-<module>") in every file?
Thanks, I'll try that!
l
That is my understanding, yes.
k
Mh, it seems to find the imports now, thanks!
👍 1
Unfortunately, aws-cdk does not like the code that is generated though. 😞
b
cc @[JB] Shagen
u
the misplaced JsModule annotation is one of the most annoying and and biggest issues we currently have with dukat ( they are difficult to pinpoint because code can compile (which is basically the main source of testing as of now)
k
Copy code
class CdkTestStack constructor(val scope: Construct, val id: String) : Stack(scope, id) {
    init {
        val lambda = Function(this, "TestLambda", object : FunctionProps {
            override var runtime: Runtime = Runtime.NODEJS_12_X
            override var code: Code = Code.fromInline("")
            override var handler: String = "index.handler"
        })
    }
}

fun main() {
    val app = App()
    CdkTestStack(app, "CdkTestStack")
}
Gets compiled to:
Copy code
...
  var App = $module$<http://_aws_cdk_core.App|_aws_cdk_core.App>;
  CdkTestStack.prototype = Object.create(Stack.prototype);
  CdkTestStack.prototype.constructor = CdkTestStack;
  function CdkTestStack(scope, id) {
    Stack.call(this, scope, id);
    this.scope = scope;
    this.id = id;
    var lambda = new Function(this, 'TestLambda', new CdkTestStack_init$ObjectLiteral());
  }
...
and cdk/node complains that
Copy code
Stack.call(this, scope, id);
          ^

TypeError: Class constructor Stack cannot be invoked without 'new'
    at new CdkTestStack (/home/arml/dev/lib/kt-js-lambda-test/build/js/packages/kt-js-lambda-test-kt-cdk/kotlin/kt-js-lambda-test-kt-cdk.js:9:11)
is there a way to make this work?
u
let me check
👋 1
k
@[JB] Shagen any luck? :)
u
Still need more clarification, @kartoffelsup - I found two declarations in aws-cdk , namely node_modules/aws-cdk/packages/aws-cdk/test/integ/bootstrap/example-cdk-app/my-test-cdk-stack.d.ts node_modules/aws-cdk/packages/@aws-cdk/custom-resources/lib/provider-framework/types.d.ts and have a feeling that I actually misunderstood what exactly declaration you are converting
k
@[JB] Shagen I've uploaded it to github: https://github.com/kartoffelsup/kt-js-lambda-cdk-test, in particular what I'm stuck on is in this module: https://github.com/kartoffelsup/kt-js-lambda-cdk-test/tree/master/kt-cdk
🙏 1
Hi @[JB] Shagen sorry for being annoying. Just wanted to check in if you had any luck in getting it to work? 🙂