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:
...
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
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?