Demonstrations of how edge cases are handled.
A
references B
which references A
which references B
... should be handled properly
@Serializable
class A(val b: B)
@Serializable
class B(val a: A)
fun main() {
val tsGenerator = KxsTsGenerator()
println(tsGenerator.generate(A.serializer(), B.serializer()))
}
You can get the full code here.
export interface A {
b: B;
}
export interface B {
a: A;
}
@Serializable
class A(
val list: List<B>
)
@Serializable
class B(
val list: List<A>
)
fun main() {
val tsGenerator = KxsTsGenerator()
println(tsGenerator.generate(A.serializer(), B.serializer()))
}
You can get the full code here.
export interface A {
list: B[];
}
export interface B {
list: A[];
}
@Serializable
class A(
val map: Map<String, B>
)
@Serializable
class B(
val map: Map<String, A>
)
fun main() {
val tsGenerator = KxsTsGenerator()
println(tsGenerator.generate(A.serializer(), B.serializer()))
}
You can get the full code here.
export interface A {
map: { [key: string]: B };
}
export interface B {
map: { [key: string]: A };
}