Describe the bug
When using #[serde(flatten)] with a zero-field struct that derives TS, the TypeScript export generation panics with the error: "[StructName here] cannot be flattened".
To Reproduce
Steps to reproduce the behavior:
Create a zero-field struct with `TS`:
#[derive(Deserialize, Serialize, TS)]
#[ts(export)]
pub struct Inner {}
// Create a parent struct that flattens the zero-field struct:
#[derive(Deserialize, Serialize, TS)]
#[ts(export)]
pub struct Outer {
#[serde(flatten)]
pub inner: Inner,
pub other_field: String,
}
- Run TypeScript export
- See panic:
"Inner cannot be flattened"
- Surprised pikachu
Expected behavior
The zero-field struct should be flattened without issue, resulting in TypeScript output equivalent to:
export type Outer {
other_field: string;
}
Or at least the library should panic indicating that zero-field structs cannot be flattened.
Version
12.0.1
Workaround:
I could just remove the whole struct and it's flatten.
Why?
That empty struct is a placeholder which could change at any moment I don't want to remove it even though it is empty
Describe the bug
When using
#[serde(flatten)]with a zero-field struct that derivesTS, the TypeScript export generation panics with the error:"[StructName here] cannot be flattened".To Reproduce
Steps to reproduce the behavior:
"Inner cannot be flattened"Expected behavior
The zero-field struct should be flattened without issue, resulting in TypeScript output equivalent to:
Or at least the library should panic indicating that zero-field structs cannot be flattened.
Version
12.0.1
Workaround:
I could just remove the whole struct and it's flatten.
Why?
That empty struct is a placeholder which could change at any moment I don't want to remove it even though it is empty