Skip to content

Commit b8c8e9e

Browse files
authored
feat: Clarify JS code inlining capabilities (#4701)
* docs: clarify JS inlining capabilities * docs: address review comments
1 parent 6f3b993 commit b8c8e9e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

docs/topics/js/js-interop.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ the surrounding tooling.
1010

1111
## Inline JavaScript
1212

13-
You can inline some JavaScript code into your Kotlin code using the [`js()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.js/js.html) function.
13+
You can inline JavaScript code into your Kotlin code using the [`js()`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.js/js.html) function.
1414
For example:
1515

1616
```kotlin
@@ -26,11 +26,16 @@ a string constant. So, the following code is incorrect:
2626
fun jsTypeOf(o: Any): String {
2727
return js(getTypeof() + " o") // error reported here
2828
}
29+
2930
fun getTypeof() = "typeof"
3031
```
3132

32-
Note that invoking `js()` returns a result of type [`dynamic`](dynamic-type.md), which provides no type safety at the
33-
compile time.
33+
> As the JavaScript code is parsed by the Kotlin compiler, not all ECMAScript features might be supported.
34+
> In this case, you can encounter compilation errors.
35+
>
36+
{style="note"}
37+
38+
Note that invoking `js()` returns a result of type [`dynamic`](dynamic-type.md), which provides no type safety at compile time.
3439

3540
## external modifier
3641

0 commit comments

Comments
 (0)