Skip to content

Commit

Permalink
fix type collection example
Browse files Browse the repository at this point in the history
  • Loading branch information
oscartbeaumont committed Jan 10, 2025
1 parent 373a42f commit 3789d62
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions examples/examples/type_collection.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use specta::Type;
use specta::{Type, TypeCollection};
use specta_typescript::Typescript;
use specta_util::TypeCollection;

#[derive(Type)]
pub struct Hello {
Expand All @@ -12,14 +11,17 @@ pub struct Hello {
pub struct Test(Hello);

fn main() {
let code = TypeCollection::default()
.register::<Hello>()
.register::<Test>()
.export(&Typescript::default())
let code = Typescript::default()
// You can use `export_to` to export to a file
.export(
TypeCollection::default()
.register::<Hello>()
.register::<Test>(),
)
.unwrap();

assert_eq!(
code,
"export type Hello = { a: number; b: boolean }\nexport type Test = Hello\n"
)
);
}

0 comments on commit 3789d62

Please sign in to comment.