madonoharu / tsify

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

Feature request: `tsify(required)` #54

Closed FredrikNoren closed 2 months ago

FredrikNoren commented 2 months ago

I quite often find myself in a spot where I want serde(default) so that old values can be de-serialized, but I don't want the typescript type of be optional. It would be amazing if there was a tsify(required) so that I could do this:

#[tsify(required)]
#[serde(default)]
pub field: String;

which would produce the type:

{
   field: string
}

Or even better, I think I would prefer if #[serde(default)] wouldn't make the field optional in the first place.