ts-rs and types from external crates
#219
Replies: 5 comments 45 replies
|
Good idea, we should probably make more use of the discussions feature! So yeah, as I said, I can definetely see cases where it'd be nice for libraries to implement/derive |
|
The "naive" approach of just exporting all dependencies with the type is the following: #[ts(export)]
struct A {
y: crate_y::Y
}
#[ts(export)]
struct B {
y: crate_y::Y
}For this, we'd expect this output:
However, the generated test for |
Possible Solution Nr.3We re-introduce something like export!, and make exporting much more explicit (and centralized in one place!). Users would have to explicitly name everything they want to export - including types their types contains. export!(
MyTypeA, MyTypeB<()> => "my_types.ts",
SomeLibraryType => "lib.ts"
);I got rid of that quite a while back and replaced it with The big advantage of this here is that you could export multiple types in one file. This isn't easily possible with the current "one test per type" approach (though it might be, with file locking, idk) |
|
@escritorio-gustavo Now that we've explored two possible solutions already, what do you think? Personally, I think I prefer the |
Uh oh!
There was an error while loading. Please reload this page.
We are talking about how to handle types from external crates (from
crates.ioor other sources) in two PRs (#211 and #218), so I thought this would be easier to followAll reactions