Make `Option` different in the struct
Closed this issue · 2 comments
xiao-e-yun commented
Is it possible?
pub struct A {
b: u8,
c: Option<u8>
}
expect
export interface A {
b: number,
c: number | null | undefined,
//Or like this if in struct
c?: number
}
escritorio-gustavo commented
I think it may be possible, but since serde converts None
to null
, I don't think it would behave as you expect
escritorio-gustavo commented
This should do what you want
#[derive(ts_rs::TS)]
pub struct A {
b: u8,
#[ts(optional)]
c: Option<u8>
}