Function typescript_type_def::write_definition_file[][src]

pub fn write_definition_file<W, T: ?Sized>(
    writer: W,
    options: DefinitionFileOptions<'_>
) -> Result<Stats> where
    W: Write,
    T: TypeDef
Expand description

Writes a TypeScript definition file containing type definitions for T to the writer W.

The resulting TypeScript module will define and export the type definition for T and all of its transitive dependencies under a root namespace. The name of the root namespace is configurable with options. Each type definition may additionally have its own nested namespace under the root namespace. The root namespace will also be the default export of the module.

The file will also include a header comment indicating that it was auto-generated by this library. This is configurable with options.

Note that the TypeScript code generated by this library is not very human-readable. To make the code human-readable, use a TypeScript code formatter (such as Prettier) on the output.