You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks so much for such a great library. It's very useful and I really appreciate the effort that's been put in!
Much like in #82, many of my structs have foreign types. Two of the ones I have that are probably quite common are url::Url (https://docs.rs/url/latest/url/) and compact_str::CompactString (https://docs.rs/compact_str/latest/compact_str/). I am not a rust expert so if my understanding of the issue is flawed, please forgive me 😄
I believe that because of the orphan rule, a derive macro cannot generate code for a type defined in a different crate. Serde has a workaround: https://serde.rs/remote-derive.html -- I could attempt to implement this for ts-rs if you think this is the right way forward.
For now I'm just generating a string via ts(type = 'string') which is fine but with some types misses quite a bit.
The text was updated successfully, but these errors were encountered:
You're completely right that the orphan rule is the problem here.
For now, the solution was just to add a lot of optional cargo features to ts-rs. When enabled, these then implement TS for the corresponding crate.
I'm not against having something comparable to serde's remote derive. For me, having features like uuid-compat for the most common crates and overriding types with #[ts(type = '..')] has been good enough though.
For this library, it would probably just require one attribute, maybe #[ts(as = some::other::Type)].
If questions come up while implementing this, feel free to ask, happy to help.
Thanks so much for such a great library. It's very useful and I really appreciate the effort that's been put in!
Much like in #82, many of my structs have foreign types. Two of the ones I have that are probably quite common are
url::Url
(https://docs.rs/url/latest/url/) andcompact_str::CompactString
(https://docs.rs/compact_str/latest/compact_str/). I am not a rust expert so if my understanding of the issue is flawed, please forgive me 😄I believe that because of the orphan rule, a derive macro cannot generate code for a type defined in a different crate. Serde has a workaround: https://serde.rs/remote-derive.html -- I could attempt to implement this for ts-rs if you think this is the right way forward.
For now I'm just generating a
string
viats(type = 'string')
which is fine but with some types misses quite a bit.The text was updated successfully, but these errors were encountered: