-
-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Labels
bugSomething isn't workingSomething isn't working
Description
To reproduce, run the following program:
[dependencies]
# latest trunk
specta = { git = "https://github.com/specta-rs/specta", rev = "ff4ba3a908cfe7552692aab50d74cdd487cae57f", features = ["derive"] }
specta-typescript = { git = "https://github.com/specta-rs/specta", rev = "ff4ba3a908cfe7552692aab50d74cdd487cae57f" }
serde = { version = "1.0.216", features = ["derive"] }
serde_json = "1.0.133"
use specta::Type as _;
#[derive(serde::Serialize, specta::Type)]
enum MyEnum {
Variant {
#[serde(flatten)]
inner: MyInnerStruct,
},
}
#[derive(serde::Serialize, specta::Type)]
struct MyInnerStruct {
some_field: i32,
}
fn main() {
let mut types = specta::TypeCollection::default();
MyEnum::definition(&mut types);
let s = specta_typescript::Typescript::default().export(&types).unwrap();
println!("{s}");
println!("------");
let s = serde_json::to_string_pretty(&MyEnum::Variant { inner: MyInnerStruct { some_field: 42 } }).unwrap();
println!("{s}");
}This outputs:
// This file has been generated by Specta. DO NOT EDIT.
export type MyEnum = { Variant: { inner: MyInnerStruct } };
export type MyInnerStruct = { some_field: number };
------
{
"Variant": {
"some_field": 42
}
}
Instead it should be something like
export type MyEnum = { Variant: { some_field: number } };
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working