-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working