Open
Description
Double and Int are both converted directly to number
. This is confusing on the TypeScript side.
@Serializable
data class Position(
val x: Double,
val y: Double,
val level: Int,
)
// generated
export interface Position {
x: number;
y: number;
level: number; // level looks the same as x and y, but if I produce a JSON message with 1.5, KXS will error
}
Unsigned numbers (because they are value classes) are converted to type aliases, e.g.
export interface Score {
goals: UInt;
}
export type UInt = number;
In TypeScript this isn't safe (UInt
can accept any numeric value, despite its name) - but it gives a good indication, and can be enhanced with brand typing (#7).
Can the other numeric primitives be exported as type aliases?
export type Byte = number
export type Short = number
export type Int = number
export type Long = number
export type Float = number
export type Double = number