|
2 | 2 |
|
3 | 3 | # Kotlinx Serialization TypeScript Generator
|
4 | 4 |
|
5 |
| -Create TypeScript interfaces from Kotlinx Serialization classes. |
| 5 | +[Kotlinx Serialization TypeScript Generator](https://github.com/adamko-dev/kotlinx-serialization-typescript-generator) |
| 6 | +creates TypeScript interfaces from |
| 7 | +[Kotlinx Serialization](https://github.com/Kotlin/kotlinx.serialization/) |
| 8 | +classes. |
6 | 9 |
|
7 | 10 | ```kotlin
|
8 | 11 | @Serializable
|
@@ -39,23 +42,31 @@ The Kotlinx Serialization API should be used to generate TypeScript. The
|
39 | 42 | [`SerialDescriptor`s](https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization.descriptors/-serial-descriptor/index.html)
|
40 | 43 | are flexible and comprehensive enough to allow for accurate TypeScript code, without any deviation.
|
41 | 44 |
|
| 45 | +The aim is to create TypeScript interfaces that can accurately produce Kotlinx Serialization |
| 46 | +compatible JSON. |
| 47 | + |
| 48 | +The Kotlinx Serialization API should be used to generate TypeScript. The |
| 49 | +[`SerialDescriptor`s](https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization.descriptors/-serial-descriptor/index.html) |
| 50 | +are flexible and comprehensive enough to allow for accurate TypeScript code, without any deviation. |
| 51 | + |
42 | 52 | See [the docs](./docs) for working examples.
|
43 | 53 |
|
44 | 54 | ## Status
|
45 | 55 |
|
46 | 56 | This is a proof-of-concept.
|
47 | 57 |
|
48 |
| -| | Status | Notes | |
49 |
| -|---------------------------------------|----------------------------------------------------------|:-------------------------------------------------------------------------------------------------| |
50 |
| -| Kotlin multiplatform | ❓ | The codebase is multiplatform, but only JVM has been tested | |
51 |
| -| `@SerialName` | ✅/⚠ | The serial name is directly converted and might produce invalid TypeScript | |
52 |
| -| Basic classes | ✅ [example](./docs/basic-classes.md) | | |
53 |
| -| Nullable and default-value properties | ✅ [example](./docs/default-values.md) | | |
54 |
| -| Value classes | ✅ [example](./docs/value-classes.md) | | |
55 |
| -| Enums | ✅ [example](./docs/enums.md) | | |
56 |
| -| Lists | ✅ [example](./docs/lists.md) | | |
57 |
| -| Maps | ✅/⚠ [example](./docs/maps.md) | Maps with complex keys are converted to an ES6 Map, [see](./docs/maps.md#maps-with-complex-keys) | |
58 |
| -| Polymorphism - Sealed classes | ✅/⚠ [example](./docs/polymorphism.md#sealed-classes) | Nested sealed classes are ignored, [see](./docs/polymorphism.md#nested-sealed-classes) | |
59 |
| -| Polymorphism - Open classes | ❌ [example](./docs/abstract-classes.md) | Not implemented. Converted to `type MyClass = any` | |
60 |
| -| `@JsonClassDiscriminator` | ❌ | Not implemented | |
61 |
| -| Edge cases - circular dependencies | ✅ [example](./docs/edgecases.md) | | |
| 58 | +| | Status | Notes | |
| 59 | +|---------------------------------------|-----------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------| |
| 60 | +| Kotlin multiplatform | ❓ | The codebase is multiplatform, but only JVM has been tested | |
| 61 | +| `@SerialName` | ✅/⚠ | The serial name is directly converted and might produce invalid TypeScript | |
| 62 | +| Basic classes | ✅ [example](./docs/basic-classes.md) | | |
| 63 | +| Nullable and default-value properties | ✅ [example](./docs/default-values.md) | | |
| 64 | +| Value classes | ✅ [example](./docs/value-classes.md) | | |
| 65 | +| Enums | ✅ [example](./docs/enums.md) | | |
| 66 | +| Lists | ✅ [example](./docs/lists.md) | | |
| 67 | +| Maps | ✅/⚠ [example](./docs/maps.md) | Maps with complex keys are converted to an ES6 Map, [see documentation](./docs/maps.md#maps-with-complex-keys) | |
| 68 | +| Polymorphism - Sealed classes | ✅/⚠ [example](./docs/polymorphism.md#sealed-classes) | Nested sealed classes are ignored, [see documentation](./docs/polymorphism.md#nested-sealed-classes) | |
| 69 | +| Polymorphism - Open classes | ❌ [example](./docs/abstract-classes.md) | Not implemented. Converted to `type MyClass = any` | |
| 70 | +| `@JsonClassDiscriminator` | ❌ | Not implemented | |
| 71 | +| JSON Content polymorphism | ❌ [example](./docs/polymorphism.md#json-content-polymorphism) | Not implemented. Converted to `type MyClass = any` | |
| 72 | +| Edge cases - circular dependencies | ✅ [example](./docs/edgecases.md) | | |
0 commit comments