Skip to content

Commit 1de5e01

Browse files
authored
docs: add enum class as valid exportable type (#4831)
1 parent 5c86ff0 commit 1de5e01

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

docs/topics/js/js-to-kotlin-interop.md

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -160,30 +160,31 @@ and setter methods static members in that object or the class containing the com
160160

161161
See how Kotlin types are mapped to JavaScript ones:
162162

163-
| Kotlin | JavaScript | Comments |
164-
|-----------------------------------------------------------------------------|----------------------------|-------------------------------------------------------------------------------------------|
165-
| `Byte`, `Short`, `Int`, `Float`, `Double` | `Number` | |
166-
| `Char` | `Number` | The number represents the character's code. |
167-
| `Long` | Not supported | There is no 64-bit integer number type in JavaScript, so it is emulated by a Kotlin class. |
168-
| `Boolean` | `Boolean` | |
169-
| `String` | `String` | |
170-
| `Array` | `Array` | |
171-
| `ByteArray` | `Int8Array` | |
172-
| `ShortArray` | `Int16Array` | |
173-
| `IntArray` | `Int32Array` | |
174-
| `CharArray` | `UInt16Array` | Carries the property `$type$ == "CharArray"`. |
175-
| `FloatArray` | `Float32Array` | |
176-
| `DoubleArray` | `Float64Array` | |
177-
| `LongArray` | `Array<kotlin.Long>` | Carries the property `$type$ == "LongArray"`. Also see Kotlin's Long type comment. |
178-
| `BooleanArray` | `Int8Array` | Carries the property `$type$ == "BooleanArray"`. |
179-
| `List`, `MutableList` | `KtList`, `KtMutableList` | Exposes an `Array` via `KtList.asJsReadonlyArrayView` or `KtMutableList.asJsArrayView`. |
180-
| `Map`, `MutableMap` | `KtMap`, `KtMutableMap` | Exposes an ES2015 `Map` via `KtMap.asJsReadonlyMapView` or `KtMutableMap.asJsMapView`. |
181-
| `Set`, `MutableSet` | `KtSet`, `KtMutableSet` | Exposes an ES2015 `Set` via `KtSet.asJsReadonlySetView` or `KtMutableSet.asJsSetView`. |
182-
| `Unit` | Undefined | Exportable when used as return type, but not when used as parameter type. |
183-
| `Any` | `Object` | |
184-
| `Throwable` | `Error` | |
185-
| Nullable `Type?` | `Type | null | undefined` | |
186-
| All other Kotlin types (except for those marked with `JsExport` annotation) | Not supported | Includes Kotlin's [unsigned integer types](unsigned-integer-types.md). |
163+
| Kotlin | JavaScript | Comments |
164+
|------------------------------------------------------------------|---------------------------|--------------------------------------------------------------------------------------------|
165+
| `Byte`, `Short`, `Int`, `Float`, `Double` | `Number` | |
166+
| `Char` | `Number` | The number represents the character's code. |
167+
| `Long` | Not supported | There is no 64-bit integer number type in JavaScript, so it is emulated by a Kotlin class. |
168+
| `Boolean` | `Boolean` | |
169+
| `String` | `String` | |
170+
| `Array` | `Array` | |
171+
| `ByteArray` | `Int8Array` | |
172+
| `ShortArray` | `Int16Array` | |
173+
| `IntArray` | `Int32Array` | |
174+
| `CharArray` | `UInt16Array` | Carries the property `$type$ == "CharArray"`. |
175+
| `FloatArray` | `Float32Array` | |
176+
| `DoubleArray` | `Float64Array` | |
177+
| `LongArray` | `Array<kotlin.Long>` | Carries the property `$type$ == "LongArray"`. Also see Kotlin's Long type comment. |
178+
| `BooleanArray` | `Int8Array` | Carries the property `$type$ == "BooleanArray"`. |
179+
| `List`, `MutableList` | `KtList`, `KtMutableList` | Exposes an `Array` via `KtList.asJsReadonlyArrayView` or `KtMutableList.asJsArrayView`. |
180+
| `Map`, `MutableMap` | `KtMap`, `KtMutableMap` | Exposes an ES2015 `Map` via `KtMap.asJsReadonlyMapView` or `KtMutableMap.asJsMapView`. |
181+
| `Set`, `MutableSet` | `KtSet`, `KtMutableSet` | Exposes an ES2015 `Set` via `KtSet.asJsReadonlySetView` or `KtMutableSet.asJsSetView`. |
182+
| `Unit` | Undefined | Exportable when used as return type, but not when used as parameter type. |
183+
| `Any` | `Object` | |
184+
| `Throwable` | `Error` | |
185+
| `enum class Type` | `Type` | Enum entries are exposed as static class properties (`Type.ENTRY`). |
186+
| Nullable `Type?` | `Type | null | undefined` | |
187+
| All other Kotlin types, except for those marked with `@JsExport` | Not supported | Includes Kotlin's [unsigned integer types](unsigned-integer-types.md). |
187188

188189
Additionally, it is important to know that:
189190

0 commit comments

Comments
 (0)