1+ [ ![ ] ( https://jitpack.io/v/adamko-dev/kotlinx-serialization-typescript-generator.svg )] ( https://jitpack.io/#adamko-dev/kotlinx-serialization-typescript-generator )
2+
13# Kotlinx Serialization TypeScript Generator
24
3- Create TypeScript interfaces from Kotlin classes
5+ Create TypeScript interfaces from Kotlinx Serialization classes.
46
57``` kotlin
68@Serializable
@@ -10,7 +12,7 @@ data class PlayerDetails(
1012)
1113
1214println (
13- KxsTsGenerator ().generate(Color .serializer().descriptor )
15+ KxsTsGenerator ().generate(Color .serializer())
1416)
1517```
1618
@@ -21,4 +23,30 @@ interface PlayerDetails {
2123}
2224```
2325
26+ The aim is to create TypeScript interfaces that can accurately produce Kotlinx Serialization
27+ compatible JSON.
28+
29+ The Kotlinx Serialization API should be used to generate TypeScript. The
30+ [ ` SerialDescriptor ` s] ( https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization.descriptors/-serial-descriptor/index.html )
31+ are flexible and comprehensive enough to allow for accurate TypeScript code, without any deviation.
32+
2433See [ the docs] ( ./docs ) for working examples.
34+
35+ ## Status
36+
37+ This is a proof-of-concept.
38+
39+ | | Status | Notes |
40+ | ---------------------------------------| ----------------------------------------------------------| :-------------------------------------------------------------------------------------------------|
41+ | Kotlin multiplatform | ❓ | The codebase is multiplatform, but only JVM has been tested |
42+ | ` @SerialName ` | ✅/⚠ | The serial name is directly converted and might produce invalid TypeScript |
43+ | Basic classes | ✅ [ example] ( ./docs/basic-classes.md ) | |
44+ | Nullable and default-value properties | ✅ [ example] ( ./docs/default-values.md ) | |
45+ | Value classes | ✅ [ example] ( ./docs/value-classes.md ) | |
46+ | Enums | ✅ [ example] ( ./docs/enums.md ) | |
47+ | Lists | ✅ [ example] ( ./docs/lists.md ) | |
48+ | Maps | ✅/⚠ [ example] ( ./docs/maps.md ) | Maps with complex keys are converted to an ES6 Map, [ see] ( ./docs/maps.md#maps-with-complex-keys ) |
49+ | Polymorphism - Sealed classes | ✅/⚠ [ example] ( ./docs/polymorphism.md#sealed-classes ) | Nested sealed classes are ignored, [ see] ( ./docs/polymorphism.md#nested-sealed-classes ) |
50+ | Polymorphism - Open classes | ❌ [ example] ( ./docs/abstract-classes.md ) | Not implemented. Converted to ` type MyClass = any ` |
51+ | ` @JsonClassDiscriminator ` | ❌ | Not implemented |
52+ | Edge cases - circular dependencies | ✅ [ example] ( ./docs/edgecases.md ) | |
0 commit comments