JetBrains/kotlin — pull request #55 by develar (2012-05-13 15:57:53+00:00)
Title: kotlin js translator should produce strict, ecma 5 compliant code

First iteration of http://devnet.jetbrains.net/thread/436214?tstart=0

1) new argument -target. "5" or "3". default: 3 (old code, ecma 3).
1.1) idea plugin: check second line of ".kotlin-js" for target (see example file https://gist.github.com/2687708)

2) Custom accessors are ignored now, (see JsAstUtils:319). Will be implemented after your review of this pull request.

3) Next TODO:

Current translation:

Kotlin:

object {val nodeId = nodeId; val selector = selector}

JavaScript:

Kotlin.object.create({initialize:function(){
Object.defineProperties(this, {nodeId:{value:nodeId}, selector:{value:selector}});
}
})

It is not good and must be just

Object.create(null, {nodeId:{value:nodeId}, selector:{value:selector}}).

4) It works for me and I can remove my workaround method "kotlinObjectToJs". But in any case I still need to delete "this.initializing = klass;" in kotlin_lib (because native side doesn't expect this property). It is a next task — actually, we can use more ecma5 compliant way to define classes.

5) todo: generated JS still doesn't contain "use strict" statement.