5f3e296f19
There are multiple ways to declare a named variable-like entity in Kotlin: 1. val/var variable declaration 2. destructuring declaration 3. parameter of a function 4. parameter of a lambda 5. destructured lambda parameter 6. for-loop's variable declaration 7. catch block exception declaration 8. val in when 9. field declaration Out of them, only variable and field can be assignable, in other words, they can be on the left hand side of an assignment. Val/var variable declarations were already supported. So, we needed to just support field initialization and tell the backend that other ways are prohibited. Function and lambda parameters were already been supported. So, the only thing to explain to the backend are remaining ways. #KT-39113 Fixed #KT-34048 Fixed
JavaScript Translation
This module performs the translation of Kotlin source code to JavaScript.
There are various Kotlin APIs to JavaScript environments in the standard library.
Compiling the Kotlin Standard Library for JavaScript
The Kotlin Standard Library for JS is built with gradle, see the corresponding module's ReadMe.
Reusing JVM based test cases in JavaScript
Any Kotlin test cases using the org.junit.Test annotation and the kotlin.test package, such as this test case are automatically converted to JavaScript using QUnit.
This allows the test cases to be run directly in a web page in any web browser.
Using the Kotlin Library in JavaScript
There is a simple sample which shows how to use the Kotlin Standard Library from inside JavaScript in a web page.
Contributing
We love contributions! The JavaScript translation could really use your help! If you fancy contributing:
- check the contributing section on general stuff like getting the code etc
- try fix one of the pending JavaScript translation issues