Closed
Description
Let's look on code
@Serializable
sealed class S {
@Serializable
class A : S()
@Serializable
class B: S()
}
@Serializable
class C(
val s: S,
val snull: S?
)
fun main() {
val tsGenerator = KxsTsGenerator()
println(tsGenerator.generate(serializer<C>()))
}
It generates the following type of script file, which is not valid.
export interface C {
s: S;
snull: S | null;
}
export type S =
| S.A
| S.B;
export namespace S {
export enum Type {
A = "S.A",
B = "S.B",
}
export interface A {
type: S.Type.A;
}
export interface B {
type: S.Type.B;
}
}
export namespace S {
export enum Type {
A = "S.A",
B = "S.B",
}
export interface A {
type: S.Type.A;
}
export interface B {
type: S.Type.B;
}
}
As I understood from debugger, there is some problems with handling nullable types, as there is something called S.A
and something called S?.A
, and deduplication doesn't work because of that.