0

I'm trying to use Kotlin to write angular JavaScript code. Here is some valid Javascript code for angular:

const AppComponent = function () {
    this.title = 'Angular Hello World Demo'
};

AppComponent.annotations = [new ng.core.Component({
    selector: 'hello-app',
    templateUrl: './app/app.component.html',
    styleUrls: ['./app/app.component.css']
})];

But I can't write proper Kotlin code to generate such form of JavaScript code.

I tried to use companion object:

class MyComponent {
   companion object {
       val annotations = ...
   }
}

But it actually generates

function MyComponent() {}
function AppComponent$Companion() {
    this.annotations = ...
}

which is not working.

Is it possible to fix it?

bashor
  • 8,073
  • 4
  • 34
  • 33
Freewind
  • 193,756
  • 157
  • 432
  • 708
  • I think it's duplicate of https://stackoverflow.com/questions/44955888/how-to-set-a-static-property-on-a-class-in-kotlin-for-javascript . @Freewind you can find a workaround there and feel free to vote the related issue https://youtrack.jetbrains.com/issue/KT-18891 – bashor Apr 09 '18 at 12:47
  • Possible duplicate of [How to set a static property on a class in Kotlin for Javascript](https://stackoverflow.com/questions/44955888/how-to-set-a-static-property-on-a-class-in-kotlin-for-javascript) – bashor Apr 09 '18 at 12:48

0 Answers0