Derive Macro typescript_type_def::TypeDef[][src]

#[derive(TypeDef)]
{
    // Attributes available to this derive:
    #[type_def]
    #[serde]
}
Expand description

A derive proc-macro for the TypeDef trait.

This macro can be used on structs and enums which also derive serde::Serialize and/or serde::Deserialize, and will generate a TypeDef implementation which matches the shape of the JSON produced by using serde_json on the target type. This macro will also read and adapt to #[serde(...)] attributes on the target type’s definition.

This macro also reads the following attributes:

  • #[type_def(namespace = "x.y.z")] on the struct/enum body puts the TypeScript type definition under a namespace of x.y.z. Note that write_definition_file will additionally place all type definitions under a root namespace (by default named types).