https://kotlinlang.org logo
#javascript
Title
# javascript
h

hikamaeng

03/26/2024, 1:20 AM
've recently been doing a lot of research on 'external'. 'External' is a keyword that essentially tells the compiler that something exists externally, so it should pass it during compilation and not worry about it in reality. What's interesting is that it works differently on each platform. Starting with 'common', only 'external fun' is allowed in JVM and Android. They do not allow external definitions other than functions, meaning they only recognize it as a feature, not as a type. This is because the arguments or return values of that external function cannot be defined as external either, so they only recognize external definitions for function usage within the types recognized by the compiler. Considering the type system and its conversion process, this is not incomprehensible. However, there are no such restrictions in Kotlin JS. External objects, interfaces, classes, vars, and vals are all allowed. Therefore, it is possible to completely wrap the JS side without the help of a separate Kotlin conversion object. Especially in such cases, a very peculiar syntax appears. For example, this is possible:
Copy code
external interface Parent
external interface Child: Parent
What's peculiar is that even though Child inherits from Parent, which is not an interface, there are no parentheses.
👀 1
t

turansky

03/26/2024, 6:30 PM
What about expect/actual - will it work for you?
h

hikamaeng

03/27/2024, 1:32 AM
There hasn't been much need for a common-level actual structure in Kotlin JS, as it has many features specialized for the browser.