Aleph-Alpha / ts-rs

Generate TypeScript bindings from Rust types
MIT License
1.08k stars 107 forks source link

Make `#[ts(concrete)]` an attribute on the type, not the generic parameters #262

Closed WilsonGramer closed 6 months ago

WilsonGramer commented 6 months ago

The syntax looks like this now:

#[derive(TS)]
#[ts(export, concrete(T = TsDriver))]
struct MyStruct<T: Driver> {
    u: T::Info,
}
NyxCode commented 6 months ago

Way nicer, thanks @WilsonGramer!

Regarding the serde bug:
I understand the reasoning of the syn maintainer, but that doesn't change the fact that there's a bug in serde.
I guess they can also take the stand that they'd like to keep the bug to discourage the syntax, but that feels pretty wrong.

Whatever, this is a nicer solution anyway, thanks!

There are still a couple of things I'd like to figure out before merging concrete into main.
For example, TS::decl behaves a bit like TS::decl_concrete right now. But this is a nice steps towords getting that branch ready, thank you!

escritorio-gustavo commented 6 months ago

I guess they can also take the stand that they'd like to keep the bug to discourage the syntax, but that feels pretty wrong.

Agreed, serde compatibility is pretty much a requirement for every Rust library. Intentionally keeping a bug that prohibits the use of valid Rust syntax on the basis that they don't like said syntax is very weird.