madonoharu / tsify

A library for generating TypeScript definitions from rust code.
Apache License 2.0
300 stars 41 forks source link

Allow type overrides at the container level #33

Open maartendeprez opened 1 year ago

maartendeprez commented 1 year ago

For types with hand-coded Serialize / Deserialize impls, it can be useful to be able to specify the typescript definition manually. This patch adds a "type" attribute at the container level, similar to the one at field level, and when set produces a type alias for the field instead of the derived struct / enum type.

I am not quite sure if my interpretation of the 'type_params' field is correct, so please verify. Also, we might want to allow free-form declarations (eg. #[tsify(type = "export interface MyType {...}")]) instead restricting the attribute to type aliasses.