-
Notifications
You must be signed in to change notification settings - Fork 142
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem? Please describe.
Currently, inline_flattened() under impl<T: TS> TS for Option<T> panics and says this can't be flattened
Line 822 in 858f413
| panic!("{} cannot be flattened", <Self as crate::TS>::name()) |
Describe the solution you'd like
From this example:
#[derive(TS, Serialize)]
#[serde(rename_all = "camelCase")]
enum Enum {
FirstOption(String),
SecondOption(bool)
}
#[derive(TS, Serialize)]
struct T {
a: String,
#[serde(flatten)]
flattened_field: Enum // I want this to be Option<Enum>
}Non optional flattened enums get parsed to something like:
{ a: string } & ({ "firstOption": string } | { "secondOption": bool })My guess is that adding ? to the enum keys creates intended behavior (either accepts one option because of | or allows undefined if none are given):
{ a: string } & ({ "firstOption"?: string } | { "secondOption"?: boolean })Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request