Skip to content

Commit bf7ae56

Browse files
committed
Merge branch 'main' into dev
# Conflicts: # README.md
2 parents bcb3c0a + 8c3491a commit bf7ae56

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

README.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,29 @@ Create TypeScript interfaces from Kotlinx Serialization classes.
66

77
```kotlin
88
@Serializable
9-
data class PlayerDetails(
10-
val name: String,
11-
val health: Float,
9+
class MyClass(
10+
val aString: String,
11+
var anInt: Int,
12+
val aDouble: Double,
13+
val bool: Boolean,
14+
private val privateMember: String,
1215
)
1316

14-
println(
15-
KxsTsGenerator().generate(Color.serializer())
16-
)
17+
fun main() {
18+
val tsGenerator = KxsTsGenerator()
19+
println(tsGenerator.generate(MyClass.serializer()))
20+
}
1721
```
1822

23+
Generated TypeScript interface:
24+
1925
```typescript
20-
interface PlayerDetails {
21-
name: string;
22-
health: number;
26+
export interface MyClass {
27+
aString: string;
28+
anInt: number;
29+
aDouble: number;
30+
bool: boolean;
31+
privateMember: string;
2332
}
2433
```
2534

@@ -30,6 +39,13 @@ The Kotlinx Serialization API should be used to generate TypeScript. The
3039
[`SerialDescriptor`s](https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization.descriptors/-serial-descriptor/index.html)
3140
are flexible and comprehensive enough to allow for accurate TypeScript code, without any deviation.
3241

42+
The aim is to create TypeScript interfaces that can accurately produce Kotlinx Serialization
43+
compatible JSON.
44+
45+
The Kotlinx Serialization API should be used to generate TypeScript. The
46+
[`SerialDescriptor`s](https://kotlin.github.io/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization.descriptors/-serial-descriptor/index.html)
47+
are flexible and comprehensive enough to allow for accurate TypeScript code, without any deviation.
48+
3349
See [the docs](./docs) for working examples.
3450

3551
## Status

0 commit comments

Comments
 (0)