From f6a0bd896af18ac8b0df23bbf6d2cba1f1d89455 Mon Sep 17 00:00:00 2001 From: Moritz Bischof Date: Sun, 20 Dec 2020 00:42:43 +0100 Subject: [PATCH] don't import types from the same file when using export! --- example/src/lib.rs | 4 +--- ts-rs/Cargo.toml | 2 +- ts-rs/src/export.rs | 6 +++++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/example/src/lib.rs b/example/src/lib.rs index 51c6853..a81a75d 100644 --- a/example/src/lib.rs +++ b/example/src/lib.rs @@ -45,11 +45,9 @@ mod export_ts { } } -#[derive(TS)] -struct X(Vec); // this will export [Role] to `role.ts` and [User] to `user.ts`. // `export!` will also take care of including imports in typescript files. export! { Role => "role.ts", - User, X => "user.ts", + User => "user.ts", } diff --git a/ts-rs/Cargo.toml b/ts-rs/Cargo.toml index b943d8b..18d970c 100644 --- a/ts-rs/Cargo.toml +++ b/ts-rs/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ts-rs" -version = "2.1.2" +version = "2.1.3" authors = ["Moritz Bischof "] edition = "2018" license = "MIT" diff --git a/ts-rs/src/export.rs b/ts-rs/src/export.rs index 6965695..f4c52fd 100644 --- a/ts-rs/src/export.rs +++ b/ts-rs/src/export.rs @@ -90,7 +90,11 @@ pub fn imports( .into_iter() .flat_map(|(id, name)| { let path = exported_files.get(&id)?; - Some((import_path(out_path, path), name)) + if path == out_path { + None + } else { + Some((import_path(out_path, path), name)) + } }) .for_each(|(path, name)| { imports