Using optional
with type
in 11.x
#414
-
Hello! I have a (weird?) use-case that doesn't seem to work in the new v11, and I don't find a good fix/alternative for it. In my case, I'm using ts-rs to shared types for the HTTP bodies (JSON) and parameters. The backend is in Rust, and I provide a TS client. For example, in v10, I was doing this #[derive(Deserialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
struct CreateCalendarEventBody {
/// Start time of the event (UTC)
#[ts(optional, type = "Date")]
pub start_time: Option<DateTime<Utc>>, /// Chrono
} export type CreateCalendarEventBody = {
/**
* Start time of the event (UTC)
*/
startTime?: Date
} Defining it as a However, in v11, it seems not possible anymore to use #[derive(Deserialize, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export, optional_fields)]
struct CreateCalendarEventBody {
/// Start time of the event (UTC)
#[ts(type = "Date")]
pub start_time: Option<DateTime<Utc>>,
} export type CreateCalendarEventBody = {
/**
* Start time of the event (UTC)
*/
startTime: Date
} I'm maybe missing something ? Don't hesitate to tell me 🙂 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey, thanks for reaching out! The error is raised here, and |
Beta Was this translation helpful? Give feedback.
-
@GuillaumeDecMeetsMore This regression should be fixed now in v11.0.1 |
Beta Was this translation helpful? Give feedback.
@GuillaumeDecMeetsMore This regression should be fixed now in v11.0.1