Skip to main content

export

Function export 

Source
pub fn export<'a>(
    exporter: &dyn AsRef<Exporter>,
    types: &Types,
    ndts: impl Iterator<Item = &'a NamedDataType>,
    indent: &str,
) -> Result<String, Error>
Expand description

Generate a group of export Type = ... Typescript string for a specific NamedDataType.

This method leaves the following up to the implementer:

  • Ensuring all referenced types are exported
  • Handling multiple type with overlapping names
  • Transforming the type for your serialization format (Eg. Serde)

We recommend passing in your types in bulk instead of doing individual calls as it leaves formatting to us and also allows us to merge the JSDoc types into a single large comment.

If you are using a custom format such as serde::format with the high-level exporter, these primitive helpers do not apply that mapping automatically. Standalone primitive usage should map both the full Types graph and any top-level DataType values with matching helpers first.