pub fn write_definition_file_from_type_infos<W>(
writer: W,
options: DefinitionFileOptions<'_>,
type_infos: &[&'static TypeInfo]
) -> Result<Stats>where
W: Write,
Expand description
Writes a TypeScript definition file containing type definitions for the given list of type info values to the given writer.
The type info values can be obtained using TypeDef::INFO
on a type.
The resulting TypeScript module will define and export the type definition
for each given type and all of thair transitive dependencies under a root
namespace. The name of the root namespace is configurable with the
root_namespace
option. 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.
If the root namespace is set to None
, no root namespace and no default
export will be added. See the docs of
root_namespace
for an important
note about using no root namespace.
The file will also include a header comment indicating that it was
auto-generated by this library. This is configurable with the
header
option.
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.